Closed indigo0086 closed 8 years ago
I don't think this is a good idea. This will break the guarantee that only the module that have added a subscription can remove it.
But we have plans for better subscription methods: https://github.com/rpominov/kefir/issues/151
It will look like this:
let unsub = Kefir.fromEvents(document.body, 'click').observe((evt) => console.log(evt.target))
unsub()
What do you think?
That would be a good solution. I guess in the mean time I can write up a simple unsubscribe function for my implementation via
clickTest.offValue(mouseClick._dispatcher._items[0].fn).
Ok, I think we can close this then.
For the off~ equivalent to on~ functions, a callback is needed to unregister the function used as the onValue callback. This requires a seperate definition of the callback or function definition as a reference to use in the offValue function. a simple preferred scenario is something like
For a simple scenario where it would be more terse to use an anonymous function in the on value, onValue should provide a zero argument equivalent that clears the callback (and possibly others).