Skip to content

Derived properties and on change listener sequence #246

Open
@dan-iway

Description

@dan-iway

I have stumbled upon this a few times now, I am not sure if this is a bug or I just fail to understand the concept here:
If there is both a change listener and a derived property depending on the same property and the change listener accesses the derived property it seems that the change listener is executed first, the derived property gets updated after that. I would expect that all derived properties are already updated when the change events are triggered.

See example code on requirebin:
view on requirebin

With this output:

B sees A changed to: 2
Trigger on A thinks B is: 2

B sees A changed to: 2
Trigger on A thinks B is: 2

B sees A changed to: 3
Trigger on A thinks B is: 3

B sees A changed to: 4

While the derived property gets updated for every change, the trigger seems unable to access B after the last change. Also the derived property is calculated 4 times in total, twice for number 2, why?

If line 23 is removed, the derived property is calculated only 3 times as expected. Why does accessing a derived property change how often it is calculated? That should only depend on its deps, right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions