connect-alt
Decorator for passing alt store state through props, heavily inspired from
react-redux::connect
How to / Installation
$ npm i -S connect-alt
II. Provide flux into your app context:
Use AltContainer for an easy integration:
;; ;; ;
III. Use into your application
This is the most performant way, it only listen for the specific store changes and not waiting for all stores to update
;;; @ static propTypes = sessionStore: PropTypesobjectisRequired { const sessionStore: currentUser = thisprops; return <pre> JSON </pre> ; }
You can pass as many stores you want to the decorator: @connect('session', 'posts', 'foo', 'bar')
, you will get them into props with the suffix Store
.
III. (Alternative) Use the decorator with a reducer function in your components
Warning, this is expensive because connect-alt
will be listening for any stores update and not the only concerned
;;; @ static propTypes = currentUser: PropTypesobjectisRequired { const currentUser = thisprops; return <pre> JSON</pre> ); }
NOTE: You will need to provide a FinalStore
on alt instance:
;; { superconfig; thisFinalStore = ; } ;
III. (Alternative 2) Combine the stores you listen and the FinalStore reducer
;;; @ static propTypes = currentUser: PropTypesobjectisRequired { const currentUser = thisprops; return <pre> JSON</pre> ); }
Examples
See isomorphic-flux-boilerplate for a complete app example.