Skip to content

feat: make resources ES6 observables #34

Description

@pemrouz

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 🤔).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions