Skip to content

Instantly share code, notes, and snippets.

@bradfordlemley
Last active May 29, 2019 23:16
Show Gist options
  • Save bradfordlemley/0d5c459dec536c6bfa6140ff67008f31 to your computer and use it in GitHub Desktop.
Save bradfordlemley/0d5c459dec536c6bfa6140ff67008f31 to your computer and use it in GitHub Desktop.
State composition with mapState
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,
});
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment