export function getCharts() { const state = store.getState(); const charts = state.chartState; if (shouldGetChart(charts, 'pop')) store.dispatch(getChart('pop')); if (shouldGetChart(charts, 'kpop')) store.dispatch(getChart('kpop')); if (shouldGetChart(charts, 'vpop')) store.dispatch(getChart('vpop')); }
const requireAuth = (nextState, replace) => { if (!store.getState().user.isLoggedIn) { replace('/'); } }
function render(req, res) { const initialState = getInitialState(req); const store = createStore(initialState); const html = ReactDOMServer.renderToString( <Provider store={store}> <App /> </Provider> ); const markup = ReactDOMServer.renderToString(<Html html={html} state={store.getState()} />); res.status(200).send(`<!DOCTYPE html>${markup}`); }
constructor(props) { super(props) this.state = { subjects: store.getState().subjects, } }
onReachEnd() { const state = this.commentsStore.getState(); if (!(state.finished || state.loading || state.error)) { this.commentsStore.dispatch(CommentsAction.fetchFromBottom(this.shot.id, state.page)); } }
store.subscribe(() => { const {messages} = store.getState() if (messages.data.length > 0) { store.dispatch({type: Types.CLEAR_MESSAGE}) alert(messages.data) } })
navigateBack() { const navigatorState = store.getState().get('navigatorState'); const currentStackScreen = navigatorState.get('index'); const currentTab = navigatorState.getIn(['routes', 0, 'index']); if (currentTab !== 0 || currentStackScreen !== 0) { store.dispatch(NavigationActions.back()); return true; } // otherwise let OS handle the back button action return false; }
const apiClient = function() { const token = store.getState().token; const params = { baseURL: URL, headers: {'Authorization': 'Token ' + token} }; return axios.create(params); }
/* eslint-enable */ const render = () => ReactDOM.render( <Counter value={store.getState()} onIncrement={() => store.dispatch({ type: INCREMENT })} onDecrement={() => store.dispatch({ type: DECREMENT })} />, document.getElementById('root') )
store.subscribe(() => { const state = store.getState(); const visibleExpenses = getVisibleExpenses(state.expenses, state.filters); console.log(visibleExpenses); });
onReachEnd() { const state = this.shotsStore.getState(); if (!(state.finished || state.loading || state.error)) { this.shotsStore.dispatch(UserShotsAction.fetchFromBottom(this.user.id, state.page)); } }
// render(App); store.subscribe(() => { const state = store.getState(); if (state.questions.length > 0) { console.info('Mounting app'); render(App); } else { console.info('App not yet mounted'); } });
store.subscribe( () => { console.log("subscriber 2", store.getState()); }, );