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

feat: make resources ES6 observables #34

Open
pemrouz opened this issue Dec 25, 2016 · 0 comments
Open

feat: make resources ES6 observables #34

pemrouz opened this issue Dec 25, 2016 · 0 comments

Comments

@pemrouz
Copy link
Collaborator

pemrouz commented Dec 25, 2016

The basic API simply streams change objects:

ripple.on('change', (name, change) => {})       // listen for all changes
ripple('resource').on('change', change => {})   // listen for changes to resource

Users should also be able to subscribe using the ES6 Observable syntax:

ripple.subscribe({ next, error, complete })
ripple('resource').subscribe({ next, error, complete })

for await (change of ripple) {}
for await (change of ripple('resource')) {}

I was thinking we could use the error handler if a stream throws, but it seems that according to this answer the observable wouldn't recover if error is called. Therefore, I don't think it should be used for application-level errors, but only when the stream is truly stopped (liked losing connection - although even that is recoverable 🤔).

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

1 participant