Skip to content

Instantly share code, notes, and snippets.

@Kelin2025
Created April 29, 2019 11:25
Show Gist options
  • Save Kelin2025/f730a1b29d789d16ce30fe4154cef834 to your computer and use it in GitHub Desktop.
Save Kelin2025/f730a1b29d789d16ce30fe4154cef834 to your computer and use it in GitHub Desktop.
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