Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HELP: desperately need .off( ) ; // the opposite of .on() #155

Open
puppetmaster3 opened this issue May 16, 2017 · 6 comments
Open

HELP: desperately need .off( ) ; // the opposite of .on() #155

puppetmaster3 opened this issue May 16, 2017 · 6 comments

Comments

@puppetmaster3
Copy link

Here is an example of .off()

In a long living app, I need to add AND remove once I no longer need a 'listener'. I can't create a new stream as there are other 'listeners'. We are now on flyd and would like to stay on, but must have something like .off().
HELP.

@paldepind
Copy link
Owner

The following should work

theStream.end(true);

This will push into the end stream and tell the stream to stop.

@puppetmaster3
Copy link
Author

That will not work, I do not want the stream to end, there are other 'listeners'.
I want others to work.
But I want one listener to be off.

@leeoniya
Copy link
Contributor

leeoniya commented May 20, 2017

i was actually looking for similar functionality to have ad-hoc reactivity (see #142 (comment))

what i ended up doing was to create dependent streams and .end(true) those as a way of "canceling" the subscriptions [1]. seems to work okay.

[1] https://github.com/leeoniya/domvm/blob/2.x-dev/src/view/addons/streamFlyd.js

@paldepind
Copy link
Owner

@puppetmaster3

Yes. But you can call end(true) on that one listener.

@puppetmaster3
Copy link
Author

@paldepind How? I'm new to streams.

@puppetmaster3
Copy link
Author

I think I got it:
const endDebugS = flyd.on((x) => console.debug(x), s);

It is not clear in docs that on() returns a stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants