Meet npm Pro: unlimited public & private packages + package-based permissions.Learn more »

@lore/connect

0.14.0-beta.3 • Public • Published

@lore/connect

Purpose

Provides a decorator for React components that allows components to specify which data they need and will automatically fetch that data if it doesn't exist. The data is either returned from the store or triggers the action they fetches the data (and notifies the store when it arrives).

Dependant Hooks

None.

Example Usage

Scenario 1: If the component doesn't need to be subscribed to changes in the store (which is the typical scenario) just pass in two arguments; the state function and the component:

connect(function(getState, props, context){
  return {
    user: getState('user.current')
  }
}, createReactClass({...}))

Scenario 2: If the component does need to be subscribed to changs in the store, pass in three arguments; options, the state function, and the component.

connect({
   subscribe: true
}, function(getState, props, context){
   return {
      user: getState('user.current')
   }
}, createReactClass({...}))

Install

npm i @lore/connect

DownloadsWeekly Downloads

1

Version

0.14.0-beta.3

License

MIT

Unpacked Size

106 kB

Total Files

98

Last publish

Collaborators

  • avatar