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

Move from Promises to Observables #76

Open
madeleineostoja opened this issue Oct 18, 2017 · 0 comments
Open

Move from Promises to Observables #76

madeleineostoja opened this issue Oct 18, 2017 · 0 comments
Assignees
Milestone

Comments

@madeleineostoja
Copy link

Simpla currently uses promises and observer methods to react to data, eg:

Simpla.get('/foo').then(...);
Simpla.observe('/foo', () => { ... });

This has a few problems:

  • Duped logic between a one-time reaction (promise) and continued reactions (observer), when really these are the same thing

  • Handshake issues when both getting and observing a path while it's in transit and filling the buffer

  • Growing number of observer methods that all do the same thing to different pieces of data (observe, observeState, observeQuery once we reimplement indexes)

Instead, Simpla should return ES6 observables, using a library like RxJS or zen-observable.

The new API would look something like this

// Get data
Simpla.get('/foo')
  .subscribe(..., { once: true });

// Observe data changes
let foo = Simpla.get('/foo')
  .subscribe(...);

// Stop an observer
foo.unsubscribe();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants