How to load an object in front and NOT get it updated real time?

Hi

I’d like to load an object in front from the database, and from that point in time I’d like it to be independant from the database object.

I’d like to make changes on it, and leave it to my liking to end up saving it (sync it with it’s sibling in databse) - or just discard my front.

That is not natively possible, what kind of workaround can we use?

Best

To avoid real-time updates on your object, try loading the data into a custom state on page load. This way, you’re only using a ‘snapshot’ of the data, and it won’t refresh with database updates. You can set the custom state on page load or with a trigger and reference the custom state in your UI elements instead of the live database object.

Hey, thanks

I didn’t know custom states were supposed to behave like that.

I tested it right away, full of hope and guilt of not knowing that… but my testing was unsuccessful.

I have a demo page with a custom state type “task”, set to a random object from DB at page load.
But the object is updated with database updates.

What did I miss?

If you update the dB entry … you are … updating the dB entry …

The idea behind the use of custom states is that you can use that data and further manipulate on-page … so that if you refresh the page you lose those states … in other words … you are just playing around with the values … until such time in which you decide to save it to the dB.

Hope the above makes sense.

That works for basic types but not objects. Or I am completely missing it.
It seems to me that the “set state” puts a reference to the object into the custom state and does not duplicate the object.

This is what I’ve done for testing :

  1. a custom state type “user” is on the page itself
  2. a button puts current user into the custom state
  3. then I have a workflow “Make change to thing” that change the custom state object, it changes one of the object fields
  4. BOOM → the change is reflected to the database “current user” that was originaly set on step 1.

Would you mind setting up a super-quick demo page so I can understand? Thanks

Lists in custom state will not update in realtime, because that data is a result of an action and states only change through actions. Bubble objects in any state will still update because it is stored as a Bubble object and is realtime.

AFAIK you cannot make a Bubble object static. You’ll need to create a psuedo object using JSON then reference that JSON to store updates client side.

As a side note, every Bubble object that gets loaded into a page will add to the realtime WU cost each time there is an update. You can overcome this by retrieving data using an API call and returning data appropriately.

1 Like

Building a JSON object client-side … awesome @ihsanzainal84 !

@bonjour_17 I was simply suggesting that instead of storing the entire object in a custom state … to store individual fields (e.g., text, number) as separate custom states. This would avoid updating the dB entry in real-time and you could manipulate the individual custom states directly to display them “dynamically-on-page” to the user.

1 Like