With proxies and patches in, this might be a time to get more inline with ES Observables to ensure interop with future libraries and patterns that may emerge as these kinds of observables become more commonplace.
I think the best thing we could offer is to implement the [Symbol.observable] function on our can-observe objects and arrays, which could return an event stream that emits a patch event for every change or patch on this object and any child/descendant observables objects/arrays.
This could really give us a foothold into the Reactive space as FRP gain more ground in the JS community, especially when ES Observables become a standard.
Brad had some ideas for implementation:
reify patches as a first-class thing in ObservationRecorder
either make a special shared symbol or an "addPatches" function
that way property changes always dispatch patches on the parent object
[Symbol.observable] could make a temp-bound observable
descend through the object graph
check for cycles with a Set of visited objects
use ObservationRecorder to add the patches for all observe objects found
Maybe we could avoid expensive recalculation by making it a stack of Observations, so for every node there's a new Observation listening for patches.
With proxies and patches in, this might be a time to get more inline with ES Observables to ensure interop with future libraries and patterns that may emerge as these kinds of observables become more commonplace.
I think the best thing we could offer is to implement the
[Symbol.observable]
function on our can-observe objects and arrays, which could return an event stream that emits a patch event for every change orpatch
on this object and any child/descendant observables objects/arrays.This could really give us a foothold into the Reactive space as FRP gain more ground in the JS community, especially when ES Observables become a standard.
Brad had some ideas for implementation:
[Symbol.observable]
could make a temp-bound observable