• Robert Knight's avatar
    Convert store selectors to receive local rather than global state · 5250a6f7
    Robert Knight authored
    Change store module selectors to receive the module's local state rather than
    the global/root state as the first argument. The majority of selectors only need
    access to the module's local state. Changing these selectors to receive the
    local rather than root state has benefits:
    
     - It avoids the need for the selectors to know about the structure of
       the root state. This can make future refactorings and re-use easier.
    
     - It is consistent with how state is accessed in the reducer functions
    
     - It will simplify typing selectors because the type of the `state`
       argument will be the same as the type of `state` returned by `init`
       and passed to `update` functions
    
     - It potentially enables automatic memoization of selectors based on
       the local state. ie. If the local state for a module has not changed as a
       result of an action, then none of the local selectors will need to be
       recomputed
    
    There are a small number of selectors that need access to state from
    multple modules. In future we may want to move these to some separate
    location but, as an incremental step, add support for "root selectors"
    to modules under a `rootSelectors` key. These selectors will still receive the
    root state as their first argument as before.
    
    This commit also adds missing tests for the `annotationExists` selector and the
    `route` module.
    
    See also https://hypothes-is.slack.com/archives/C1M8NH76X/p1595237570226700.
    5250a6f7
Name
Last commit
Last update
..
modules Loading commit data...
test Loading commit data...
create-store.js Loading commit data...
debug-middleware.js Loading commit data...
index.js Loading commit data...
use-store.js Loading commit data...
util.js Loading commit data...