A common source of error is mutation of values in reactive vars. The reactive var cannot notice a change in its value (e.g. a list) if the list is mutated in place.
A user can be mislead that it is working correctly, when another reactive variable triggers a rerender, teaching bad habits.
Detecting mutations in Python without using proxies can be done by making a deepcopy of the object, and comparing the reference to the deepcopy.
This comes at the cost of performance and memory usage, therefore we should enabled this by default in development mode (tests run in this mode by default), so app builders are aware of mistakes while developing.
In production mode we can disable the mutation checks and behave as before.
TODO:
[ ] Trigger calls to check_mutations() from several places: after an event handler (requires a change in reacton) and after a component run.
[ ] We probably do not want two equals function in solara/reacton, reconcile this.
[ ] Give an option to opt out of the mutation check per reactive var (e.g. when equals fails), or for performance reasons.
[ ] support reactive.get(copy=True) to always get a copy, even when _CHECK_MUTATIONS is False
[ ] Do we need support reactive.get(reference=True) to always get a reference, or is the opt-out enough?
A common source of error is mutation of values in reactive vars. The reactive var cannot notice a change in its value (e.g. a list) if the list is mutated in place.
A user can be mislead that it is working correctly, when another reactive variable triggers a rerender, teaching bad habits.
Detecting mutations in Python without using proxies can be done by making a deepcopy of the object, and comparing the reference to the deepcopy.
This comes at the cost of performance and memory usage, therefore we should enabled this by default in development mode (tests run in this mode by default), so app builders are aware of mistakes while developing. In production mode we can disable the mutation checks and behave as before.
TODO: