Issue with timing an exposed state

Hey forums,

I am experiencing a weird issue with timing an exposed state from a client-side action. Some useful background:

  1. I am using a client-side action, not an element action, because there is a bug where you cannot return context.async functions more than one time per browser session.
  2. I am saving the instance to the window in this manner: window.myInstance = instance
  3. I am publishing an exposed state in this client-side action from the window.myInstance

The issue is with timing. I have these workflows:

Step 1 (Publishes Exposed State) → Step 2 (Uses exposed State)

On the first run, it won’t work because step 2 executes before step 1 is able to publish the exposed state. The second run, it uses the data from the exposed state from the first run because the new data hasn’t been given to the exposed state yet.

Remember, client side actions do not have “Result of Step 1 …” exposed, so I must use exposed states. I need some help with this… running into a lot of Bubble limitations for this plugin and it’s been really annoying.

Any help would be appreciated.

1 Like

Update: I converted it to an element action just for fun (Even though it will only work one time every session) and while even using an instance that is not passed through the window, the same issue of step 2 not getting the exposed state in time is occurring …

Have you tried triggering an event after publishing the state? It’s a common pitfall, but it is solved already.

3 Likes

Thank you, this was very helpful :slight_smile:

As a general rule of thumb when designing plugin elements, publishState(s) and triggerEvent should be called in pairs. Heuristically it is the “You’ve got mail” notification.