Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass instance as first argument to callbacks

See original GitHub issue

I generally don’t like dealing with this. Mainly because of its interaction with arrow/non-arrow functions and secondly because tooling like linters can not statically determine which functions are bound and which are not, so they can not warn on a unused this.

Would it make sense to instead pass the current instance as the first argument to all callbacks? E.g. (uPlot, left, right, idx) for cursormove for example.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

leeoniyacommented, Dec 14, 2019

this is now done with the exception of .tzDate - i’ll probably leave it as-is, since it’s sufficiently different from other function-taking opts and hooks.

what ultimately convinced me was building out

leeoniyacommented, Dec 8, 2019


Could it be the last parameter instead?

this requires a high degree of confidence that function signatures are perfect and makes it impossible to non-awkwardly add more params to the existing methods without breaking changes.

I feel that’s somewhat more commonplace in JS-land

i don’t feel this way at all. do you have some examples of popular libs that do this?

and would also not be a breaking change.

before v1.0, every commit can be breaking; i don’t make the rules, but someone smart did 🤣

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using class method as callback in Python - Stack Overflow
Class method has extra "self" argument at the first position. ... place where function called I should pass class instance to this method....
Read more >
How to pass a Variable or Argument to a callback function in ...
So, It means if I pass a variable in the function which I want to use as a callback function will execute first...
Read more >
Callback function with input arguments · CodeCraft with Python2
First define two functions, the callback and the calling code, then pass the callback function into the calling code. The callback function has...
Read more >
Proper annotation for instance/classmethod using as callback
I annotated bounded callbacks with the class as a first argument, which was wrong. With that, I wanted to separate the function.
Read more >
Python callbacks
All callback functions must take two arguments. The first argument will be an object given at the time the function is registered; VMD...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found