• Robert Knight's avatar
    Add utility to watch for changes in certain values · c313ec3b
    Robert Knight authored
    This will be used to streamline a common pattern in our code for
    reacting to changes in state selected from the central Redux store.
    
    The utility is a standalone function rather than a method of the store
    so that it can easily be used with mock stores and also other data
    sources in future.
    
    ```
    watch(
      store.subscribe,
      () => store.getState().someValue,
      (currentValue, prevValue) => { /* Handle change */ },
    );
    ```
    c313ec3b
watch.js 2.4 KB