
2.but when the observableObject is like this below. toJS just return empty object such as {}

I'm confused:
Thanks very much!
Please show how the objects where created
Op vr 28 jul. 2017 04:41 schreef cdlterry notifications@github.com:
>
- toJS is validable to this kind of observableObject. It can return
correct result;
[image: image]
https://user-images.githubusercontent.com/15389663/28699622-66bc247a-737d-11e7-89fd-60566686982c.png2.but when the observableObject is like this below. toJS just return empty
object such as {}
[image: image]
https://user-images.githubusercontent.com/15389663/28699672-adf1aedc-737d-11e7-84a5-e1841f6fb3b2.pngI'm confused:
- I don't know why there are two kinds observableObject above. The
#mobx props appear in different positions. But I just simply do some
Assignment actions.- How can I deal the issue to use toJS to renturn correct result for
the second kind of observableObject?Thanks very much!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/mobxjs/mobx/issues/1117, or mute the thread
https://github.com/notifications/unsubscribe-auth/ABvGhMlmnEZlOjL160FUr3X7PBgRM8i7ks5sSUpZgaJpZM4OmEHC
.
@mweststrate
the definition and the assignment are as below:

@cdlterry looks okay so far. Can you set up a reproduction, e.g. by using jsfiddle, to demonstrate the problem? (there are some in the readme or new issue template you can directly fork from). (and on a side note: never use catch (error) {} ).
@mweststrate


It looks that when the object in the array of 'events' has getter and setter function(as screenshot below) , the observable var of 'gameEvents' will be toJS an empty obj.

The chrome console prints non-enumerable props with "lighter/slightly transparent" color. If you would consult the docs, you would learn that:
Computed values and other non-enumerable properties won't be part of the result.
So the question is, why the msg and editorName is enumerable in one case and non-enumerable in another.
@urugator
Thanks!
That is, in some cases, I use fs.readJson() in render process to get json objects, but the value is changed by electron.remote. to non-enumerable.
@urugator @mweststrate I still have the same problem. Also, I have posted a question about the same topic on SF as it not good to reopen/open an issue. Can you please have a look?
@Uneetpatel7 Can't reproduce: https://codesandbox.io/s/mobx-objectassign-tojs-7yst1
@Uneetpatel7 Async is another beast :) You are accessing the computed property before it gets assigned. It won't be accessed again later unless you read it. Computeds are not a tool for driving async code ;)

@Uneetpatel7 This should make it obvious:
https://codesandbox.io/s/mobx-objectassign-tojs-bc2ox
@urugator @FredyC I understood it well. But I have one question. Why is the log of mobx observable object same both the time. i.e before and after in your code
@Uneetpatel7 Care to elaborate? I don't follow what you mean. There is no modification of observable.
@FredyC. Yeah. As seen in The log of an observable object it remains same both the time. Precisely speaking when it is logged before the API call (when toJS() gives empty object after conversion) and after the API call (when toJS() gives the non-empty object after conversion). Concluding the question only the output of toJS() changes while the log of the observable object remains the same both the time
EDIT: I can see values in the target field of the observable object log but not in toJS conversion.https://codesandbox.io/embed/mobx-objectassign-tojs-gccwt?fontsize=14
I have the same problem for arrays that are the result of a @computed. While the array itself is there, the result of the toJS is an array of empty objects. Is there something one can do about that?
This issue was closed 2 years ago. Please open new issues instead of commenting on old ones nobody sees, except participants that were in this issue earlier.