Closed christophehenry closed 1 year ago
The first three calls to console are the changed callbacks for the initial values. The third is when you change the string value to test in the connect callback.
Pushing to an array value and adding a property to an object value won't work as expected.
As per the other ticket, value properties are getters and setters, not instance values.
https://stimulus.hotwired.dev/reference/values#change-callbacks
Stimulus invokes each change callback after the controller is initialized and again any time its associated data attribute changes. This includes changes as a result of assignment to the value’s setter.
Ok, thank you. Closing this, then.
Take this example:
This will print:
First and last prints correspond to init and
connect()
but the two in-between only correspond to the initialization only. This could be solved by using JS'Proxy
.