
A variant of Flux with
central, isolated state.
Microcosm makes it easier to control and modify state. in a pure,
centralized way. It uses pure, singleton Stores and Actions, keeping
all state encapsulated in one place. This design seeks to achieve a
reasonable trade off between the simplicity of singletons and the
privacy of class instances.

Overview
Within the context of the Flux model, Microcosm treats actions and
stores as singletons, however they do not contain any state.
Actions are called within the context of a particular instance of Microcosm:
app.push(Action, parameters)
Stores hold no state, transforming old data and parameters into a new
state:
let Store = {
addRecord(state, params) {
return state.concat(params)
}
}
Opinions
- Action CONSTANTS are automatically generated by assigning
each Action function a unique
toString
signature under the hood. - Actions dispatch parameters by returning a value, promise,
or follow the error-first callbacks convention. The promise and
error-first callback methods will only dispatch on success.
- Actions handle all asynchronous operations. Stores are
synchronous.
- Stores do not contain data, they transform it.
What is it trying to solve?
- State isolation. Requests to render applications server-side should
be as stateless as possible. Client-side libraries (such as
Colonel Kurtz) need easy
containment from other instances on the page.
- Singletons are simple, but make it easy to accidentally share
state. Microcosm keeps data in one place, operating on it
statelessly in other entities.
- Easy extension of core API and layering of features out of the
framework's scope.
Tutorials
Hello, Microcosm is a great place to
start. With that background, Design may help to
provide an additional high level overview of how things work. Beyond
that, check out the example app.
Documentation
There is documentation here. This includes high level
overviews of framework architecture, guides, and API documentation for
the individual components of Microcosm.
Inspiration