Registers a callback function that gets be invoked after the state changes.
listenerId attribute should an unique identifier of the listener
(the callback function).
To be more specific, statePath gives some granularity to control which attribute
change make the callback invoked.
There are two possible values for statePath:
statePath is a single attribute callback listens to (so callback will be invoked only when this attribute changes),
statePath must be "*" (callback is invoked when any attribute changes).
Please keep in mind in any of these cases, there changedPaths: string[] array
of changed attributes array to check which attributes changed.
The limitation is there is no possibility to listen to level-2 nested attributes.
For example, if you have a state like so:
Registers a callback function that gets be invoked after the state changes.
listenerIdattribute should an unique identifier of the listener (the callback function).To be more specific,
statePathgives some granularity to control which attribute change make the callback invoked.There are two possible values for
statePath:statePathis a single attribute callback listens to (so callback will be invoked only when this attribute changes),statePathmust be"*"(callback is invoked when any attribute changes). Please keep in mind in any of these cases, therechangedPaths: string[]array of changed attributes array to check which attributes changed.The limitation is there is no possibility to listen to level-2 nested attributes. For example, if you have a state like so:
there is no possibility to listen to
horsepowerattribute changes only (thuskey-value-state-containername).IMPORTANT: each
registerStateChangedCallbackmust be paired withunregisterStateChangedCallbackcall. Otherwise memory leaks occur.