You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add the possibility to fetch initial data from a data store to a React component. This needs a change to the ListenerMixin's listenTo method and in the store implementation as well.
Motivating Example
varaStore=Reflux.createStore({init: function(){this.listenTo(anAction,function(){this.trigger('not initial data anymore');});}getInitialData: function(){return"the initial data";// is used by Listenermixin if a component wants initial data }});varComponent=React.createClass({mixins: [Reflux.ListenerMixin],getInitialState: function(){return{};// <-- impossible to know the state if stores aren't initialized yet},componentDidMount: function(){this.listenTo(aStore,changeCallback,changeCallback);// will call changeCallback twice, during store change and // when the store has initialized// third callback should be optional},changeCallback: function(data){console.log(data);this.setState({data: data});}});
In the example, before invoking the anAction the component should be able to set the state with "the initial data" fetched from the store's getInitialData method. When invoking the anAction the component should be able to set the state with "not initial data anymore" fetched from the change event.
Thoughts?
The text was updated successfully, but these errors were encountered:
Add the possibility to fetch initial data from a data store to a React component. This needs a change to the ListenerMixin's listenTo method and in the store implementation as well.
Motivating Example
In the example, before invoking the
anAction
the component should be able to set the state with"the initial data"
fetched from the store'sgetInitialData
method. When invoking theanAction
the component should be able to set the state with"not initial data anymore"
fetched from the change event.Thoughts?
The text was updated successfully, but these errors were encountered: