OttoH / fluxex

An extended flux implement for both server/client side.

Home Page:https://www.npmjs.org/package/fluxex

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fluxex

An extended flux implement for both server/client side.

npm version Dependency Status Build Status Test Coverage Code Climate License

See the Fluxex Magic

Check example projects you can see how fluxex do server side rendering + context deliver + Full HTML react rendering!

So far we do not include these in the example, but ....coming soon!

  • api call cross server/client
  • complex action creator

Difference with Flux

Fluxex is context based flux implemention. Server side react rendering can be done easy when the flux is scoped under a request based context. Store and dispatcher are singletons in Facebook flux, but in fluxex they are not.

Fluxex

  • Fluxex is an instance, it is constructed by provided context.
  • Fluxex can be serialized by .toString() and reconstructed by the serialized string. All server side store status can be transfered to client side by this way.

Action

  • An action creator should return a promise.
  • An action creator function can be executed with .executeAction() method under a Fluxex instance.
  • When the action be .executeAction(), the Fluxex instance can be referenced by this.
  • .executeAction() will return a promise, so you can manage asynchronous actions in promise way.

Dispatcher

  • the Fluxex instance itself is a dispatcher with .dispatch() method.
  • the dispatched FOOBAR action will trigger all stores with handleFOOBAR method under the Fluxex instance.

Store

  • Store is an instance, it is constructed by serialized status.
  • Store is created by a Fluxex object automatically.
  • Store naming and prototype information are provided by the .stores property of Fluxex instance.
  • Use .getStore(name) to get the store by name from an Fluxex instance.

Usage

Define your app

Provide store {name: implementation} pairs and Html.jsx location (example):

'use strict';

var commonStores = require('fluxex/extra/commonStores');

module.exports = require('fluxex').createApp({
    page: commonStores.page,
    productStore: require('./stores/product')
}, process.cwd() + '/components/Html.jsx');

.... to be continue ...

About

An extended flux implement for both server/client side.

https://www.npmjs.org/package/fluxex

License:Other


Languages

Language:JavaScript 100.0%Language:Shell 0.0%