redux#Store JavaScript Examples

The following examples show how to use redux#Store. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: api.js    From flatris-LAB_V1 with MIT License 6 votes vote down vote up
// NOTE: This method is strictly called on the server side
export async function addCurUserToState(
  req: http$IncomingMessage,
  store: Store<State, Action>
) {
  const { sessionId } = cookie.parse(req.headers.cookie || '');
  if (sessionId) {
    try {
      const res = await fetchJson('/auth', {
        headers: {
          cookie: `sessionId=${sessionId}`
        }
      });
      const user = getValidUser(res);
      store.dispatch(auth(user));
    } catch (err) {
      // Nothing to do, user is guest
    }
  }
}
Example #2
Source File: index.js    From talk-control with Apache License 2.0 5 votes vote down vote up
/**
 * Create a Talk Control state store
 *
 * @returns {Store} - Talk control store
 */
export function createTcStore() {
    return createStore(reducers, initialState, config.logger.redux ? applyMiddleware(createLogger()) : undefined);
}