cursor-subject
v0.0.2
Published
Cursor subject
Downloads
6
Readme
RxJS Cursor Subject
Le what?
Create a Subject which also behaves like a Cursor. Allows the consumer to repeatedly refine (map) a subject to a subtree of the original data while being able to push new values on to that subtree, still updating the original, unrefined subject.
Example
import {CursorSubject} from 'cursor-subject'
const cursor = CursorSubject.create({a: {b: {c: {d: 42}}}})
const refined = cursor.refine(`a.b`)
const doubleRefined = refined.refine(`c.d`)
doubleRefined.next(55)
cursor.take(1).subscribe(::console.log) // prints {a: {b: {c: {d: 55}}}}
refined.take(1).subscribe(::console.log) // prints {c: {d: 55}}
cursor.next({a: {b: {c: {d: 100}}}})
doubleRefined.take(1).subscribe(::console.log) // prints 100