I'm having problem with Simperium.
This little plnkr allows one user to create an account on my app, and authenticate with it.
Once you authenticate, you can modify the object_to_update
object in the mydata_data
bucket with a name: value pair (press the update button to do so!).
The problem is that I always get the bucket's local callback executed when updating the object_to_update
object. I can't see why. The update is triggered locally (I don't have other remote stuff doing stuff on this page), but even triggering it locally always trigger the local callback.
The docs for local
say:
This callback is triggered whenever the library needs to check what the current local state of an object is before it sends you a notify event. This is so any local changes can be incorporated into the updated object. In the example above, you may be syncing text input from a HTML element named "mytextfield". If there is an update available (this object was changed elsewhere), the library will expect to get the current state of the object so it can incorporate the local changes with the remote changes. When you get the notify event, then you can update "mytextfield" directly.
But the update was not triggered elsewhere, I'm triggering it locally!
The only way I see for the update to succeed as intended is to duplicate the update code:
bucket.update ("object_to_update", {on: va});
in the local callback, with the exactly same on
and va
values, but what's the point in duplicating it in the first place? There must be another explanation.
I believe the library is simply querying your app for the data it should send to the server. It's expected that calls to local
will always return the most recent local data for an object (even if you've changed it elsewhere in your app).