-
-
Notifications
You must be signed in to change notification settings - Fork 596
Provide Background on ObjectState #127
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
Comments
Ultimately, it's because the JS SDK is designed as a client-first SDK. The use cases we see are almost all from a web app, and this architecture allows developers to build apps that stay in sync. It also opens us up to doing things like offline storage, similar to the other SDKs (which, in fact, implemented this type of behavior first). As this is designed for client applications, it's also not ideal for node ones. It is for this reason that node applications, by default, do not have "single instance" mode enabled, because as you point out, global state is generally a bad idea. Instead, they currently use the same backing mechanism, but do not share data between Parse Object instances. Otherwise, it would be difficult to implement a beforeSave type interaction (no way to see the old state and the new state simultaneously). We don't take architectural decisions lightly. We decided that a global storage structure would unify the architectures of the 4 major SDKs and make development much easier for us (Parse engineers) and end developers by reducing bugs and weird edge cases. |
Archiving this as a discussion issue. |
Hey everyone, I know there is a lot going on and it is the holidays so I apologize in advance if this is a nuisance but I'd like some background on the global object state being maintained JS SDK. I'm not quite sure how to describe this issue except to phrase it as an honest question.
I appreciate but don't fully comprehend the efforts of trying to keep objects up to date for the user. It seems like global state for a NodeJS application in any capacity is a bad idea. In fact, global user state is part of what triggered the previous re-write of the Parse JS SDK.
Clearly, if an object is read, changed locally but modified somewhere else before saving it, you will smash over the first change when you go to persist the object. However, there has to be a more elegant way to do this.
If that is the reason this part of the SDK exists it might it be better to keep a version # or something that is provided with the update to ensure that you only update the object if the version in the DB still matches that of the object you want to modify (if greater then fail).
As implemented, this produces very surprising behavior such as what is observed by myself and others in #91 and #111. Perhaps some additional background would help us understand why the bookkeeping in and around ObjectState is needed.
The text was updated successfully, but these errors were encountered: