Skip to content

Reactive statements and unexpected line execution order #4516

@pushkine

Description

@pushkine

The compiler reorganizes the order at which lines are run such that reactive statements are only run at the end, that already by itself creates unexpected output such as :

let value = "hi"
$: value = "hello";
console.log(value) // prints "hi"

but then, when you'd expect reactive statements to at least keep the right order between themselves, this happens:

let value = "hi"
$: console.log(value) // prints "hello"
$: value = "hello";

the current component initialization order is the following :

  1. run static statements
  2. run "one time" dynamic statements
  3. run dynamic statements

related : #4371

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions