This is the global AppDispatcher. Every action must go through the AppDispatcher.

Returns a Kefir.pool() that we use a bus.

createAppDispatcher(): Kefir.pool
Returns
Kefir.pool:

appStateFactory

src/appStateFactory.js

A channel consists of:

  • a name (channel)
  • map of ActionTypes
  • map of Reducers indexed by ActionType
  • map of ActionFunctions indexed by ActionType

See createChannels for more details.

A saga consists of:

  • a name (channel)
  • map of ActionTypes
  • SagaHandlersFn higher order function that accepts a sagas interface and returns the SagaHandlers.

See createSagas for more details.

A middleware is function with the following signature: store => next => action

appStateFactory(opts: Object): {AppState, AppDispatcher}
Parameters
opts (Object)
Name Description
opts.channels Array<Channels> (default [])
opts.sagas Array<Sagas> (default [])
opts.middleware Array<Middleware>
opts.redux Object (default {redux:{middleware:[],reducers:{}}})
Returns
{AppState, AppDispatcher}: the AppState and its dispatcher to send messages.

Hey, look! Something like a monad (dang, forget I said the "m" word.)

StateWithSideEffects is basically state plus an array of messages (the side effects to be executed).

You can combine it with State or with another StateWithSideEffects, or add side effects to an existing StateWithSideEffects.

new StateWithSideEffects(state: any, sideEffects: any)
Parameters
state (any)
sideEffects (any)
Instance Members
constructor(state, sideEffects)
combine(b)

Constructor helper

state(state: State): StateWithSideEffects
Parameters
state (State = {})
Returns
StateWithSideEffects: instance

DangerouslySlowContainer

src/components/Container.js

Natural interface---just wrap a child view in this container class and pass values via props. No complex state functions. Because it supports parent React props, it can be inefficient for arbitrary prop changes.

new DangerouslySlowContainer(props: any, __dangerouslyEnableSlowness: any)

Extends React.Component

Parameters
props (any)
__dangerouslyEnableSlowness (any)

Doesn't support parent React props. However, you can define complex state functions.

Do NOT use anonymous functions to define getInitialState, getObservableState, getDefaultProps!

createContainer(opts: Object): Function
Parameters
opts (Object)
Name Description
opts.getDefaultProps Function (default ()=>{}) container default props. Passed to child as props.
opts.getInitialState Function (default ()=>{}) container initial state. Passed to child as props.
opts.getObservableState Function (default ()=>{}) pass observables here. Observable values passed to child as props
opts.propTypes any (default {}) container propTypes.
Returns
Function: that receives the child view

Supports parent React props at the expense of potentially being inefficient:

Every #componentWillReceiveProps forces observer re-initialization. Therefore it is your responsibility to ensure that it doesn't get called too often.

Since container props and state both get mapped as child props, state overriddes props with the same name.

Do NOT use anonymous functions to define getInitialState, getObservableState, getDefaultProps!

createDangerouslySlowContainer(opts: Object): Function
Parameters
opts (Object)
Name Description
opts.getDefaultProps Function (default ()=>{}) container default props. Passed to child as props.
opts.getInitialState Function (default ()=>{}) container initial state. Passed to child as props.
opts.getObservableState Function (default ()=>{}) pass observables here. Observable values passed to child as props
opts.propTypes any (default {}) container propTypes.
opts.__dangerouslyEnableSlowness any (default true)
Returns
Function: that returns the container

Creates a special channel for redux reducers. The main differences between this and createChannels are:

  1. createChannels assumes a single reducer per action type. createReduxReducers passes all actions to every reducer, as per the redux style.
  2. createChannels maps each channel to a single top-level state property. createReduxReducers maps every reducer to a top-level state property. But internally, all messages flow through a single redux channel.

Limitations

Currently, redux#combineReducers is not supported.

Message Dispatching

To pass a message to a redux reducer from an rflux app, use this format:

  • channel:String = reduxChannelName (see ./reduxChannelName)
  • actionType:String
  • payload: {//actual redux action }
createReduxReducers(Reducers: Map<string, Function>): Function
Parameters
Reducers (Map<string, Function>)
Name Description
Reducers.Reducers any
Reducers.AppDispatcher any
Returns
Function: the redux reducers channel

This is the reserved redux channel name used internally. Do NOT use this as a channel name.

reduxChannelName

This injects the middleware into the AppDispatcher. Middleware can stop propagation of events to observables by not calling "next(action)". Middleware can also transform actions or dispatch their own actions.

reduxMiddlewareFactory(opts: Object): MiddlewareFactory
Parameters
opts (Object)
Name Description
opts.AppDispatcher kefirEmitter
opts.rawMiddleware Array<middleware>
Returns
MiddlewareFactory: factory

This AppDispatcher is middleware aware.

appDispatcher(): kefirEmitter
Returns
kefirEmitter: the AppDispatcher

Call the action and return the result (as an observable)

callObservable

reduxSagaMiddleware

src/redux/ReduxSaga.js
reduxSagaMiddleware(channel: string, opts: Object): Object
Parameters
channel (string)
opts (Object)
Name Description
opts.ActionTypes Map map whose keys are the names of the side effects
opts.SagaActionFunctions Map (optional) map of action functions
opts.SagaHandlers Map map of handler functions
Returns
Object: redux middleware