Current collected state Current
Observed since 20 Oct, 17:39 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
0flux
Typed state management
A small, typed state management library.
Example:
'use strict';
import * as Flux from '0flux';
interface TodoAction {
name: string;
id: number;
}
const container = new Flux();
const dispatcher = {
addTodo: container.action<TodoAction>(),
removeTodo: container.action<TodoAction>(),
};
interface State {
todos: TodoAction[];
}
const todoState = container.state<State>((getState, setState) => {
dispatcher.addTodo.bind((todoAction) => {
setState({
todos: getState().todos.concat([ todoAction ])
});
});
dispatcher.removeTodo.bind((todoAction) => {
setState({
todos: getState().todos.filter((item) => {
return item.id !== todoAction.id;
})
});
});
return {
todos: []
};
});
const julia = dispatcher.addTodo.dispatch({
id: 0,
name: 'julia'
});
const clone = dispatcher.addTodo.dispatch({
id: 1,
name: 'evil julia clone'
});
console.log('evil clone detected:');
console.log(todoState.current);
dispatcher.removeTodo.dispatch(clone);
console.log('evil clone eliminated:');
console.log(todoState.current);
Download counts and popularity will appear here as the collector receives them.
Declarations describe requirements; they are not a resolved dependency graph.
Source distribution
{
"shasum": "fd6307538e680617a520b3d28521bbc6979eaa01",
"tarball": "https://registry.npmjs.org/0flux/-/0flux-0.0.4.tgz",
"integrity": "sha512-ubaNPLPgGUO3wiIZBRvfZv84s27Y20qBF7hdZ9+GWPdaQF1eglDgx1wPQMwNnFctwEzgcky9cdhjSLPOItZMOA==",
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEUCIQCFkGtcLqfLnFdn7P1nSpompnhlXKVHSm/kWsvq1v6uuAIgJe+l7JJFvHGDLAUAOxkvkTLivgyZN4zCTgmL3PA3QmI="
}
]
}Observed since 20 Oct, 17:39 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:5d47ff93f8c7ea051b68a2e27990eedf7a72d03e2e5f9a164db24c7e0af30e63