-
Notifications
You must be signed in to change notification settings - Fork 1
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
extract() #1
Comments
Alternatively: const extract$: Observable<{a: A, c: C}> = store.extract({
a: state => state.a,
c: state => state.b.c
}) |
The second version is less type-safe, but more concise. Both alternatives are viable. |
The second version (state selectors) would also support: const extract$: Observable<{a: A, c: C}> = store.extract({
a: state => store.lens.focusOn('a').read(state),
c: state => store.lens.focusOn('b').focusOn('c').read(state)
}) Which is quite verbose. However, if the const extract$: Observable<{a: A, c: C}> = store.extract({
a: store.lens.focusOn('a').read,
c: store.lens.focusOn('b').focusOn('c').read
}) Which is way more concise. Anyway, it appears that binding functions to the lens would be most useful in many cases. |
Binding reading functions to lenses is now an issue in immutable-lens: |
Due to TypeScript compilator type inference limitations, the version with selectors would actually look like: const extract$: Observable<{a: A, c: C}> = store.extract({
a: (state: State) => state.a,
c: (state: State) => state.b.c
}) Which is not ideal either. Maybe another version using lenses should be considered: const extract$: Observable<{a: A, c: C}> = store.extract({
a: store.lens.focusOn('a'),
c: store.lens.focusOn('b').focusOn('c')
}) |
Finally, |
Example:
extract$
only emits for new values ofa
orc
The text was updated successfully, but these errors were encountered: