Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: extensibility draft #4

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

WIP: extensibility draft #4

wants to merge 1 commit into from

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
1 participant