How to use mwp-store - 8 common examples

To help you get started, we’ve selected a few mwp-store examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github meetup / meetup-web-platform / packages / mwp-core / src / renderers / browser-render.jsx View on Github external
export function resolveAppProps(
	routes: Array,
	reducer: Reducer,
	middleware: Array = []
): Promise {
	const basename = window.APP_RUNTIME.appContext.basename || '';
	const findMatches = getFindMatches(routes, basename);
	const createStore = getBrowserCreateStore(findMatches, middleware);
	const store = createStore(reducer, getInitialState(window.APP_RUNTIME));

	// find the matched routes, and then resolve their components - mutate
	// the route object so that the overall `routes` object contains
	// resolved `component` properties for the current location
	const resolveComponents = (): Promise => {
		// get an array of matched routes
		const matchedRoutes = findMatches(window.location);
		// resolve components in parallel (AJAX chunk requests)
		return Promise.all(
			matchedRoutes.map(matchedRoute => {
				if (matchedRoute.route.getComponent) {
					return matchedRoute.route.getComponent();
				}
				return Promise.resolve(matchedRoute.route.component);
			})
github meetup / meetup-web-platform / packages / mwp-core / src / renderers / browser-render.jsx View on Github external
export function resolveAppProps(
	routes: Array,
	reducer: Reducer,
	middleware: Array = []
): Promise {
	const basename = window.APP_RUNTIME.appContext.basename || '';
	const findMatches = getFindMatches(routes, basename);
	const createStore = getBrowserCreateStore(findMatches, middleware);
	const store = createStore(reducer, getInitialState(window.APP_RUNTIME));

	// find the matched routes, and then resolve their components - mutate
	// the route object so that the overall `routes` object contains
	// resolved `component` properties for the current location
	const resolveComponents = (): Promise => {
		// get an array of matched routes
		const matchedRoutes = findMatches(window.location);
		// resolve components in parallel (AJAX chunk requests)
		return Promise.all(
			matchedRoutes.map(matchedRoute => {
				if (matchedRoute.route.getComponent) {
					return matchedRoute.route.getComponent();
				}
				return Promise.resolve(matchedRoute.route.component);
			})
		).then(components => {
github meetup / meetup-web-platform / packages / mwp-core / src / renderers / server-render.jsx View on Github external
const initialState = {
					config: {
						apiUrl: API_ROUTE_PATH,
						baseUrl: host,
						enableServiceWorker,
						requestLanguage,
						supportedLangs,
						initialNow: new Date().getTime(),
						variants: getVariants(state),
						entryPath: url.pathname, // the path that the user entered the app on
						media: getMedia(userAgent, userAgentDevice),
					},
					flags,
				};

				const createStore = getServerCreateStore(
					getRouteResolver(routes, basename),
					middleware,
					request
				);
				return Promise.resolve(createStore(reducer, initialState));
			});
github meetup / meetup-web-platform / packages / mwp-consumer / src / server-app.js View on Github external
import { makeRenderer$ as makeServerRenderer$ } from 'mwp-core/lib/renderers/server-render';
import makeRootReducer from 'mwp-store/lib/reducer';

const routes = require('./app/routes').default;
const reducer = makeRootReducer();

// the server-side `renderRequest$` Observable will take care of wrapping
// the react application with the full HTML response markup, including ``,
// `` and its contents, and the `
github meetup / meetup-web-platform / packages / mwp-test-utils / src / mockApp.jsx View on Github external
import React from 'react';
import Helmet from 'react-helmet';
import makeRootReducer from 'mwp-store/lib/reducer';
import { Forbidden, NotFound, Redirect } from 'mwp-router';

export const clientFilename = 'client.whatever.js';
export const reducer = makeRootReducer();

export const ROOT_INDEX_CONTENT = 'this is the life';
const ChildWrap = props =>
	<div>
		{props.children}
	</div>;
const MockRootIndex = props =&gt;
	<div>
		{ROOT_INDEX_CONTENT}
	</div>;
export const FOO_INDEX_CONTENT = 'yo dawg i heard you like foo';
const MockFooIndex = props =&gt;
	<div>
		
		{FOO_INDEX_CONTENT}
	</div>;
github meetup / meetup-web-platform / packages / mwp-core / src / renderers / browser-render.jsx View on Github external
export function resolveAppProps(
	routes: Array,
	reducer: Reducer,
	middleware: Array = []
): Promise {
	const basename = window.APP_RUNTIME.basename || '';
	const resolveRoutes = getRouteResolver(routes, basename);
	const createStore = getBrowserCreateStore(resolveRoutes, middleware);
	const store = createStore(reducer, getInitialState(window.APP_RUNTIME));
	return resolveRoutes(window.location).then(() =&gt; ({
		routes,
		store,
		basename,
	}));
}
github meetup / meetup-web-platform / packages / mwp-core / src / renderers / browser-render.jsx View on Github external
export function resolveAppProps(
	routes: Array,
	reducer: Reducer,
	middleware: Array = []
): Promise {
	const basename = window.APP_RUNTIME.basename || '';
	const resolveRoutes = getRouteResolver(routes, basename);
	const createStore = getBrowserCreateStore(resolveRoutes, middleware);
	const store = createStore(reducer, getInitialState(window.APP_RUNTIME));
	return resolveRoutes(window.location).then(() =&gt; ({
		routes,
		store,
		basename,
	}));
}
github meetup / meetup-web-platform / packages / mwp-core / src / renderers / server-render.jsx View on Github external
const initializeStore = resolvedRoutes => {
			const createStore = getServerCreateStore(
				getFindMatches(resolvedRoutes, appContext.basename),
				middleware || [],
				request
			);
			const initialState = { config: appContext };
			return Promise.resolve(createStore(reducer, initialState));
		};

mwp-store

Redux store management for MWP apps

MIT
Latest version published 1 year ago

Package Health Score

39 / 100
Full package analysis

Similar packages