Last active
May 8, 2022 04:00
-
-
Save Kelin2025/eb1bf9564ad2fc2d9091a6c0685e055b 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 } from 'effector' | |
const $name = createStore('Anton') | |
const $surname = createStore('Kosykh') | |
// Creates a store with an object of stores states | |
const $profile = combine({ | |
name: $name, | |
surname: $surname | |
}) | |
// Pass the list of stores and callback to create a computed store | |
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