Created
April 29, 2019 11:25
-
-
Save Kelin2025/f730a1b29d789d16ce30fe4154cef834 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combine, createStoreObject } from 'effector' | |
const $name = createStore('Anton') | |
const $surname = createStore('Kosykh') | |
// createStoreObject creates store with object of stores states | |
const $profile = createStoreObject({ | |
name: $name, | |
surname: $surname | |
}) | |
// combine accepts the list of stores and callback that combines 'em | |
const $isValid = combine( | |
$name, | |
$surname, | |
(name, surname) => name.length && surname.length | |
) | |
console.log($profile.getState()) // { name: 'Anton', surname: 'Kosykh' } | |
console.log($isValid.getState()) // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment