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)
// Get data
Simpla.get('/foo')
.subscribe(..., { once: true });
// Observe data changes
let foo = Simpla.get('/foo')
.subscribe(...);
// Stop an observer
foo.unsubscribe();
Simpla currently uses promises and observer methods to react to data, eg:
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