How to use the flux/createFlux function in flux

To help you get started, we’ve selected a few flux 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 iam4x / isomorphic-flux-boilerplate / app / main.js View on Github external
import debug from 'debug'
// Paths are relative to `app` directory
import createFlux from 'flux/createFlux'

import ApiClient from '../shared/api-client'
import universalRender from '../shared/universal-render'

const { NODE_ENV } = process.env
if (NODE_ENV === 'development') debug.enable('dev,koa')

const client = new ApiClient()
const flux = createFlux(client)

universalRender({ flux }).catch((err) => debug('dev')(err))
github iam4x / isomorphic-flux-boilerplate / server / router.jsx View on Github external
export default async function(ctx) {
  // Init alt instance
  const client = new ApiClient(ctx.get('cookie'))
  const flux = createFlux(client)

  // Get request locale for rendering
  const locale = ctx.cookies.get('_lang') ||
    ctx.acceptsLanguages(require('../internals/config/private').locales) ||
    'en'

  const { messages } = require(`data/${locale}`)

  // Get auth-token from cookie
  const username = ctx.cookies.get('_auth')

  // Populate store with locale
  flux
    .getActions('locale')
    .switchLocale({ locale, messages })
github iam4x / isomorphic-flux-boilerplate / test / helpers / mount.js View on Github external
export default (Component, props = {}, customfluxInstance) => {
  const client = new ApiClient()
  const flux = (typeof customfluxInstance === 'object') ?
    customfluxInstance : createFlux(client)

  if (customfluxInstance === true) return flux

  const { messages } = require('data/en')

  flux
    .getActions('locale')
    .switchLocale({ locale: 'en', messages })

  const wrapper = mount(
    ,
    { context: { flux } }
  )

  return { flux, wrapper }
}