๐
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 { createStore, createEffect } from 'effector' | |
| const getPost = createEffect('Fetch posts') | |
| const $isLoading = createStore(false) | |
| const $post = createStore(null) | |
| const $error = createStore(null) | |
| $isLoading | |
| .on(getPost, () => true) |
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 | |
| }) |
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 { interval } from 'rxjs' | |
| import { fromObservable } from 'effector' | |
| //emit value in sequence every 1 second | |
| const tick = interval(1000) | |
| const tickEvent = fromObservable(tick) | |
| //output: 0,1,2,3,4,5.... | |
| tickEvent.watch(console.log) |
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
| const $names = createStore([]) | |
| const $completed = createStore([]) | |
| const $todos = combine( | |
| $names, | |
| $completed, | |
| (names, completed) => names.map((name, i) => ({ name, completed: completed[i] }) | |
| ) | |
| $names |
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
| export const NameField = createField({ | |
| view: ({ value, onChange }) => <Input value={value} onChange={onChange} /> | |
| }) |
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 | |
| }) |
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
| name: Docs | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| branches: [ master ] | |
| jobs: | |
| build: | |
| name: Build docs |
OlderNewer