Actions read old state values even if they are changed

I have a page that has the following workflow:

Ignore all other workflows except the very first one (purple). So here I:

  1. Get the local storage value called Token (works)
  2. Run a javascript to bubble that uses the token and fetches the boolean yes or no (it also works, its value called auth does change after this action is run, I can see on my page when I debug)
  3. However, on step 3, when I set the state of this page (called Authenticated) to the value of the auth (set from the javascript to bubble in step 2 and again I can confirm that value changes), steps 4 and 5 read the state of the page Authentication as empty and thus “no”.

Why is that? I feel like actions run at the same time and whatever values they read (steps 3-5) they do not then dare to read the new value.

I know that I can just delete the step 3 and run step 4 and 5 by just reading the value auth from step 2 but I tried that too and it failed the same way

So I just tested another thing… If I create a custom state for the javascript to bubble element and set to true after it ran and make all other subsequent steps to run only on that state to be true then they work as I presume they read the values only after the state is set to true

Actually only works in slow mode, not in normal…

It is very possible you’re running into an issue with the synchronous workflow steps - these steps don’t necessary function one after the other, in the order you have them laid out. Your step 3 ‘set state’ is most likely setting the state with the data that has yet to be updated in step 2. Is it possible to add an ‘Only when’ condition to step 3, with the condition being ‘result of step 2’ or similar?

1 Like

Step 2 is client side action, he needs the value from JavascriptToBubble element, not sure if that fires and Event like plugins do? If not need a “When condition is true” and trigger it when the state changes somehow

1 Like

If 1 & 2 are synchronous, put steps 3 and after into a JS to Bubble function event and call that function last in step 2.