How to use the mwp-store/lib/browser.getInitialState function in mwp-store

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);
			})
		).then(components => {
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(() => ({
		routes,
		store,
		basename,
	}));
}

mwp-store

Redux store management for MWP apps

MIT
Latest version published 2 years ago

Package Health Score

39 / 100
Full package analysis

Similar packages