Skip to content

Instantly share code, notes, and snippets.

@bradfordlemley
Last active May 29, 2019 22:19
Show Gist options
  • Save bradfordlemley/465b3ac6c766e0d962f6ec7301f006d8 to your computer and use it in GitHub Desktop.
Save bradfordlemley/465b3ac6c766e0d962f6ec7301f006d8 to your computer and use it in GitHub Desktop.
Adding methods to composed state
import { mapState } from '@stated-library/core';
const todoLib = createTodoLib();
const counterLib = createCounter();
const appState$ = mapState(
[todoLib.state$, counterLib.state$],
([todoLibState, counterLibState]) => ({
todos: todoLibState.todos,
counter: counterLibState,
total: counterLibState + todoLibState.todos.length,
addTodo: todoLib.addTodo,
});
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment