trevordevore / levure

Application development framework for LiveCode
MIT License
32 stars 14 forks source link

Assign stacks in the root `behaviors` folder to the `stackFiles` of the `app` stack #154

Open trevordevore opened 4 years ago

trevordevore commented 4 years ago

When the LiveCode engine loads a stack file with a behavior property it immediately tries to resolve it. If it can't resolve it then the behavior silently fails to load and an app won't function as intended.

Example scenario where the behavior will not be associated with the stack:

  1. Stack A is a behavior script.
  2. Stack B has Stack A assigned to it as a behavior.
  3. You load Stack B into memory and Stack A is not assigned to the stackFiles property of Stack B (or any other stack already in memory).
  4. You load Stack A into memory.

When Stack B opens Stack A is not available and cannot be found by the engine. Thus the behavior assignment fails and your code doesn't work as expected.

Levure currently loads all behaviors into memory and then dispatches a LoadBehavior message to each one. Originally this allowed a script only stack to assign a parent behavior and to ensure that a parent behavior was in memory. Now that LiveCode supports with behavior when defining a script only stack it isn't necessary.

By assigning each behavior stack file to the stackFiles property of the app stack all behaviors will resolve properly when the engine first requests them. The LoadBehavior message can be removed and Levure can rely on engine features in order to provide a development experience that doesn't leave the developer scratching their head as to why something doesn't work because a behavior silently failed to load in the background.