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

missing data when using async deserializer and mobx observables #109

Open
sven-petersen opened this issue Nov 19, 2019 · 4 comments
Open

Comments

@sven-petersen
Copy link

sven-petersen commented Nov 19, 2019

Hello,

I am facing issues with an async deserialisation in combination with mobx observables. I have put together a small example: https://jsfiddle.net/w5rzm9t8/ .
I would have expected the output to be the same in both samples. Unfortunately in the second example I am missing some values after deserialisation.

There seems to be an issue when using async deserialisation when combined with an mobx Observable. For example it starts to work when I change

const thingResolver = (v, ctx, old, cb) => {
  setTimeout(() => cb(null, v.map(id => new Thing(id))), 0);
};

to

const thingResolver = (v, ctx, old, cb) => {
 cb(null, v.map(id => new Thing(id)));
}

Can you advise if it is an error on my side, not supported, or unexpected behavior?
Thanks!

@mweststrate
Copy link
Member

mweststrate commented Jan 17, 2020 via email

@sven-petersen
Copy link
Author

Hi @mweststrate , I have created the tests. Hope this helps..

@pyrogenic
Copy link
Collaborator

pyrogenic commented Jan 20, 2020

See test case fixes sven-petersen#1 — let me know if the same change fixes your actual problem as well.

@pyrogenic
Copy link
Collaborator

pyrogenic commented Jan 21, 2020

@mweststrate it seems MobX relies on field declarations (see class Person from the docs) but Node 10 (which tavis uses for this project) doesn't support them:

/home/travis/build/mobxjs/serializr/test/mobx.js:15
519        data = undefined
520             ^
521
522  SyntaxError: Unexpected token =

I can reproduce this locally using nvm to run Node 10 instead of 13 (stable):

$ nvm exec 10 yarn run coverage
. . .
/Users/josh/github/pyrogenic/serializr/test/mobx.js:15
        data = undefined
             ^

SyntaxError: Unexpected token =
$ nvm exec 13 yarn run coverage
. . .
1..226
# tests 226
# pass  226

# ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants