Time delay between Page Data property set and use

Think I’m missing something about declarative programming:

The Page Data property ‘prevURL’ is set in On Page Enter:
Set
Set

‘prevURL’ is used in the Context Logic of a text display.
Context Logic
Content logic

When ‘prevURL’ is first read it is null
Console
Console

The Console shows the timestamp delays from when ‘prevURL’ is set; presumably the 0 delay is when the null is returned. Why there are three more calls to the content logic is a mystery.

Questions:

  • why is the context logic trying to use the property value before it’s available?
  • is there a better way to deal with this ‘feature’ than the if-null check?
  • what causes the three ‘extra’ calls to the content logic? (by this time the property value is available).

Hello @Jim_Austin

  • why is the context logic trying to use the property value before it’s available?

we can not know what value is available until to run your logic to give you a chance to run any logic.

  • is there a better way to deal with this ‘feature’ than the if-null check?

see the answer above, plus as an alternative, you can hide components which are not ready for rendering using the Visibility Logic handler, if it returns false all the children won’t be rendered.

  • what causes the three ‘extra’ calls to the content logic? (by this time the property value is available).

It depends on your logic if you modify any DataModels above (including PageData/AppData) it runs a render phase and its logic handlers.
The On Page Enter runs after the first (initial) render and since you modify the PageData it triggers another re-render phase.

You can find more in the doc UI Rendering - Backendless UI Builder Developer Guide

Regards, Vlad

Thanks Vlad, seems my mistake revolves around attributing imperative processing sequence to the component tree: assuming that the page processing (setting the page properties) would occur before processing (content) in a component (the text component) down the UI component tree.

This example shows that’s not correct, so the if-null check or Visibility ‘protection’ is necessary.
(note: ‘context’ should be ‘content’ in the writeup)