FluxibleFlux 應(yīng)用可插拔容器
Fluxible 是用于 Flux 應(yīng)用的可插拔容器。
特征:
-
服務(wù)器可免費(fèi)使用單體模式進(jìn)行渲染
-
無(wú)狀態(tài)異步操作
-
便于集成的高階組件
-
增強(qiáng)磁通流動(dòng)
-
可在 Flux 內(nèi)容上增加你的接口
-
更新至 React 0.13
示例代碼:
import Fluxible from 'fluxible';
import React from 'react';
import {connectToStores, createStore, provideContext} from 'fluxible/addons';
// Action
const action = (actionContext, payload) => {
actionContext.dispatch('FOO_ACTION', payload);
};
// Store
const FooStore = createStore({
storeName: 'FooStore',
handlers: {
'FOO_ACTION': 'fooHandler'
},
initialize: () => { // Set the initial state
this.foo = null;
},
fooHandler: (payload) => {
this.foo = payload;
},
getState: () => {
return {
foo: this.foo
}
}
});評(píng)論
圖片
表情
