-
-
Notifications
You must be signed in to change notification settings - Fork 123
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
how do I use fromStream with mobx-react observer? #77
Comments
the `current` method is tracked, so if you use it you get updated when it
updates in the future. See also the unit-tests
Op vr 1 sep. 2017 om 09:27 schreef devdoomari <notifications@github.com>:
… in TS, when I do:
const someSignal = fromStream(someStream);
I only get someSignal of type:
{
current: {},
dispose: () => ...
}
which ...doesn't seem like a mobx observable.
Is there an example of using fromStream with mobx-react's observer?
Thank you!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#77>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhPzxxoUVLwcSIIMhwv33kEvIgbPCks5sd7HjgaJpZM4PJzI0>
.
|
@mweststrate |
`.current()` is an observable, so you can just use it in the `render` of an
observer component and it will react to future updates. Mobx utils is
written in typescript, so type inference should be correct.
Op ma 4 sep. 2017 om 10:12 schreef devdoomari <notifications@github.com>:
… @mweststrate <https://github.com/mweststrate>
is this the right unit-test file?
https://github.com/mobxjs/mobx-utils/blob/master/test/observable-stream.js
it doesn't seem to give any example of using mobx-react's @observer and
fromStream...
Also, since I'm using typescript, I don't know what to make of
fromStream's return type :(
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#77 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhLfj8ygQX1L1Z_Md8nx0i4ZFlXxfks5se7DrgaJpZM4PJzI0>
.
|
uh... could you post a specific example code? so far, are you saying ( * I might understand things wrong *):
will do? (and that SomeComponent will auto-rerender whenever someSignal is updated?) |
yes that is correct
Op ma 4 sep. 2017 om 10:29 schreef devdoomari <notifications@github.com>:
… uh... could you post a specific example code?
I'm not that smart enough to understand & implement that on my code...
so far, are you saying ( * I might understand things wrong *):
@observable // from mobx-react
class SomeComponent extends React.Component<{ ... }, { ... }> {
render() {
const signalValue = this.props.someSignal.current();
return ( <p> {signalValue} </p> );
}
}
will do? (and that SomeComponent will auto-rerender whenever someSignal is
updated?)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#77 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhPg1bd9bRsU0LbftJ32jlz2pB4tWks5se7TzgaJpZM4PJzI0>
.
|
but use @observe instead of @observable
Op ma 4 sep. 2017 om 10:33 schreef Michel Weststrate <mweststrate@gmail.com
…:
yes that is correct
Op ma 4 sep. 2017 om 10:29 schreef devdoomari ***@***.***>:
> uh... could you post a specific example code?
> I'm not that smart enough to understand & implement that on my code...
>
> so far, are you saying ( * I might understand things wrong *):
>
> @observable // from mobx-react
> class SomeComponent extends React.Component<{ ... }, { ... }> {
> render() {
> const signalValue = this.props.someSignal.current();
> return ( <p> {signalValue} </p> );
> }
> }
>
> will do? (and that SomeComponent will auto-rerender whenever someSignal
> is updated?)
>
> —
> You are receiving this because you were mentioned.
>
>
> Reply to this email directly, view it on GitHub
> <#77 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABvGhPg1bd9bRsU0LbftJ32jlz2pB4tWks5se7TzgaJpZM4PJzI0>
> .
>
|
ok! thanks for your guidance! closing! ps: do you think this should be added to mobx-util docs? (or example)? |
in TS, when I do:
I only get someSignal of type:
which ...doesn't seem like a mobx observable.
Is there an example of using fromStream with mobx-react's observer?
Thank you!
The text was updated successfully, but these errors were encountered: