-
Notifications
You must be signed in to change notification settings - Fork 4
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
Limitation #19
Comments
Anyone? |
Hey Rom, Could you give an example of async action that mutate model/store state? To make it work with import { types, flow } from 'mobx-state-tree';
import { mst, shim, action } from 'classy-mst';
const AsyncData = types.model({ data: '' });
class AsyncCode extends shim(AsyncData) {
@action
run() {
const self = this; // <-- I have to add this ugly self pointer to make it work inside generator.
function* generate() {
const response = yield Promise.resolve('This gets lost');
self.data = response; // <-- `this` will not work here, since generator has different scope.
}
return(flow(generate)());
}
}
const Async = mst(AsyncCode, AsyncData);
Async.create().run().then(
(result) => console.log(result)
); P.S Overall async actions looks pretty messy, do you have plan to work this around? |
Hey @rznzippy ! Am not using |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello
Thanks for trying to build a classy layer on top of mobx-state-tree.
I remember reading few months ago somewhere (on your repo? blog?) about some limitation of classy-mst. Are there any MST usage we cannot do with it?
The text was updated successfully, but these errors were encountered: