type Unsubscribe = ( ) => void ; param store returns export const getStoreWatcher = ( store ) => { return < T > ( selector , onChange ) => { let currentVal = selector ( store . getState ( ) ) ; const unsubscribe = store . subscribe ( ( ) => { const newVal = selector ( store . getState ( ) ) ; if ( newVal !== currentVal ) { currentVal = newVal ; onChange ( newVal ) ; } } ) ; return unsubscribe ; } ; } ;