Migrating from Watch to SignalsMixin in the Signals Package #326
-
From the Signals package changelog, it is clear that after version 5.4.0, the SignalsMixin is recommended to replace any implementation that previously used Watch. I’ve noticed a significant change in how the "surgical" rebuild process works now, likely due to this update. This suggests that we should refactor our current code to adopt the new approach to ensure compatibility and potentially improve performance. However, I couldn’t find a comprehensive guide on how to properly migrate from the old Watch pattern to the new SignalsMixin. The only documentation I’ve found so far is the SignalsMixin reference, but it lacks an in-depth explanation of the migration process. Has anyone else come across detailed resources or documentation regarding this change? Any guidance or examples on best practices for migrating to SignalsMixin would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
For context I am needing to remove quite a few legacy extension methods that were a mix of the behavior and DX that I was aiming for. With SignalsMixin it completely encapsulates the signals to the widget and automatically rebuild and dispose each signal as needed. The Watch widget now uses the SignalsMixin internally too. I choose not to deprecate the .watch() extension as I think there is a lot of value still for stateless widgets but using the Watch widget is preferred since it will clean up faster and allows for surgical rendering. The SignalsMixin is only needed if you want the auto rebuilding widgets since you can still use regular signals and the Watch widget in the build method. The mixin is very close to how Lit and Angular do the update lifecycles with signals. After the recent update I can finally update signals exactly as expected and all the tests are working correctly now without extra rebuilds. |
Beta Was this translation helpful? Give feedback.
For context I am needing to remove quite a few legacy extension methods that were a mix of the behavior and DX that I was aiming for.
With SignalsMixin it completely encapsulates the signals to the widget and automatically rebuild and dispose each signal as needed. The Watch widget now uses the SignalsMixin internally too.
I choose not to deprecate the .watch() extension as I think there is a lot of value still for stateless widgets but using the Watch widget is preferred since it will clean up faster and allows for surgical rendering.
The SignalsMixin is only needed if you want the auto rebuilding widgets since you can still use regular signals and the Watch widget in the build method. T…