lore-hook-connect

Provides the connect decorator for data retrieval

reducerActionMap

This map determines which reducer is inspected for data, and which action is invoked if that data doesn't exist. You can also use this map to override the default reducer-action mapping or associate reducers and actions that weren't created by the framework (such as a custom action or reducer you created).

There are seven getState blueprints built into the framework, with mappings provided below, based on the actions and reducers automatically created by the conventions of the framework.

The * in the mappings below is special syntax that means "put the name of the model here". It allows you to say "this mapping applies to all models". For example, *.find will apply to tweet.find, user.find, etc.

You can reuse built-in blueprints by setting the value of blueprint to the name of the blueprint you want to reuse.

reducerActionMap: {
  '*.all': {
    action: null,
    reducer: '*.byCid',
    blueprint: 'all'
  },
  '*.byCid': {
    action: null,
    reducer: '*.byCid',
    blueprint: 'byCid'
  },
  '*.byId': {
    action: '*.get',
    reducer: '*.byId',
    blueprint: 'byId'
  },
  '*.find': {
    action: '*.find',
    reducer: '*.find',
    blueprint: 'find'
  },
  '*.findAll': {
    action: '*.find',
    reducer: '*.find',
    blueprint: 'findAll'
  },
  '*.first': {
    action: '*.find',
    reducer: '*.find',
    blueprint: 'first'
  }
}

If the built-in blueprints don't work for you, you can use a custom blueprint by providing an object as the value of the blueprint. The code below mimics the built-in singleton blueprint, which is used by the lore-hook-auth hook to retrieve the currentUser.

reducerActionMap: {
  'currentUser': {
    action: 'currentUser',
    reducer: 'currentUser',
    blueprint: {
      getPayload: function(reducerState, params) {
        return reducerState;
      },
      callAction: function(action, params) {
        return action().payload;
      }
    }
  }
}