Skip to content

Instantly share code, notes, and snippets.

@Kelin2025
Last active May 8, 2022 04:00
Show Gist options
  • Save Kelin2025/eb1bf9564ad2fc2d9091a6c0685e055b to your computer and use it in GitHub Desktop.
Save Kelin2025/eb1bf9564ad2fc2d9091a6c0685e055b to your computer and use it in GitHub Desktop.
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