You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In fact, since the event handler is necessarily added inside a closure where component is available, maybe it should only be bound if this is used, and the handler should be augmented like so:
// this...varlongpressHandler=template.events.longpress.call(component,button,function(event){varroot=component.get();component.set({count: root.count+1});});// rather than this:varlongpressHandler=template.events.longpress.call(component,button,function(event){varroot=this.__svelte.root;component.set({count: root.count+1});});
That would obviate the button.__svelte reference altogether, allowing us to get rid of some code (though you'd still need something analogous to track the index in each blocks in situations like this).
The text was updated successfully, but these errors were encountered:
Follow-up to #429. Binding callbacks is cheap, but not free, so we should avoid it if we can.
In this example...
...the callback needs to be bound, because the event handler needs a reference to
root
forcount
. In this example......it doesn't.
In fact, since the event handler is necessarily added inside a closure where
component
is available, maybe it should only be bound ifthis
is used, and the handler should be augmented like so:That would obviate the
button.__svelte
reference altogether, allowing us to get rid of some code (though you'd still need something analogous to track the index ineach
blocks in situations like this).The text was updated successfully, but these errors were encountered: