What is it?
observe function that can be used to create observable sources for an arbitrary object's property assignements and method calls.
Why might you need it?
If you need to convert an imperative API to an observable API, you might find this useful.
Install the package using NPM:
npm install rxjs-observe --save
TypeScript 3.0 or later is required, as the type declaration for
observe uses generic rest parameters.
Pass an object instance to
observe and receive an
observables object - that contains observable sources for the object's properties and methods - and a
;;;observables.name.subscribeconsole.logname;proxy.name = "Bob";
observe can be passed optional callbacks that will be implemented in the proxy - the observed instance does not need to implement them - and forwarded to an observable with the same name:
observe can be called inside a constructor and the
proxy can be returned, as in this Angular component:
However, such a component implementation is ... unconventional, so proceed with caution, but ... YOLO.