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

how do I use fromStream with mobx-react observer? #77

Closed
devdoomari opened this issue Sep 1, 2017 · 7 comments
Closed

how do I use fromStream with mobx-react observer? #77

devdoomari opened this issue Sep 1, 2017 · 7 comments

Comments

@devdoomari
Copy link

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!

@mweststrate
Copy link
Member

mweststrate commented Sep 4, 2017 via email

@devdoomari
Copy link
Author

@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 :(

@mweststrate
Copy link
Member

mweststrate commented Sep 4, 2017 via email

@devdoomari
Copy link
Author

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?)

@mweststrate
Copy link
Member

mweststrate commented Sep 4, 2017 via email

@mweststrate
Copy link
Member

mweststrate commented Sep 4, 2017 via email

@devdoomari
Copy link
Author

ok! thanks for your guidance! closing!

ps: do you think this should be added to mobx-util docs? (or example)?
for someone like me, this might not be very obvious

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

No branches or pull requests

2 participants