Pass instance as first argument to callbacks
See original GitHub issueI 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:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 https://leeoniya.github.io/uPlot/demos/pad-scale.html
@alextarrell
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 don’t feel this way at all. do you have some examples of popular libs that do this?
before v1.0, every commit can be breaking; i don’t make the rules, but someone smart did 🤣