|
@@ -192,12 +192,12 @@ Spruce.store('form', {
|
|
|
email: 'support@ryangjchandler.co.uk'
|
|
|
})
|
|
|
|
|
|
-Spruce.watch('form.email', (old, next) => {
|
|
|
- // do something with the values here
|
|
|
+Spruce.watch('form.email', value => {
|
|
|
+ // do something with the new value here
|
|
|
})
|
|
|
```
|
|
|
|
|
|
-In the above snippet, when we change the value of `form.email` either from a component or externally in a separate JavaScript file, our callback will be invoked and will receive the old value, as well as the new value. This can be useful for running automatic inline validation when a property changes, or triggering an action elsewhere in another component without the need for dispatching events.
|
|
|
+In the above snippet, when we change the value of `form.email` either from a component or externally in a separate JavaScript file, our callback will be invoked and will receive the new value. This can be useful for running automatic inline validation when a property changes, or triggering an action elsewhere in another component without the need for dispatching events.
|
|
|
|
|
|
> **Note**: you can get stuck in an watch loop if you're updating other store properties that also have watchers defined.
|
|
|
|