Skip to content

Conversation

@kosich
Copy link
Owner

@kosich kosich commented Oct 22, 2020

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)

@kosich kosich mentioned this pull request Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extensibility

2 participants