How to use the falcor.HttpDataSource function in falcor

To help you get started, we’ve selected a few falcor 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 ustccjw / tech-blog / client / store / configureStore.js View on Github external
import { createFalcorMiddleware, falcorReducer } from 'redux-falcor'
import falcor from 'falcor'
import { reduxReactRouter, routerStateReducer } from 'redux-router'
import { createHistory } from 'history'
import promiseMiddleware from 'redux-promise'
import { warningMiddleware } from '../middleware'
import * as reducers from '../reducer'
import routes from '../route'

const reducer = combineReducers({
	...reducers,
	entities: falcorReducer,
	router: routerStateReducer,
})
const model = new falcor.Model({
	source: new falcor.HttpDataSource('/model.json'),
})

let finalCreateStore = null
if (process.env.NODE_ENV === 'development') {
	const devTool = require('../dev-tool')
	const { persistState } = require('redux-devtools')
	finalCreateStore = compose(
		applyMiddleware(promiseMiddleware, createFalcorMiddleware(model),
			warningMiddleware),
		reduxReactRouter({
			routes,
			createHistory,
		}),
		devTool.instrument(),
		persistState(window.location.href.match(
			/[?&]debug_session=([^&]+)\b/)),