rxjs-proxify
rxjs-proxify copied to clipboard
WIP: extensibility draft
This allows adding functions on the proxy fields (fix #3)
E.g.:
interface Extension {
readValue<S>(this:S): S extends ObservableProxy<infer A, unknown> ? A : never;
}
const x: Extension = {
readValue() { return this… }
}
const source = proxify(of({ a: 1 }, { a: 2 }), x);
const d = source.a.readValue() // d: number
This might be handy if combined with rxjs-autorun:
// RxJS :: Autorun + Proxify
const s = statify({ a: '🐰', b: '🏡' });
autorun(() => s.b.$() + s.a._()); //🏡🐰
s.b.next('🛸'); //🛸🐰
I don't quite like the typing output and code should be refactored to include this feature. Also, it's not clear at what level should this extension be applied and when dropped (observable/subject/behaviorSubject)