import {createStore, createEvent} from 'effector'
const add = createEvent()const sub = createEvent()const reset = createEvent()
const counter = createStore(0) .on(add, (count, n) => count + n) .on(sub, (count, n) => count - n) .reset(reset)
counter.watch(n => console.log('counter:', n))// counter: 0add.watch(n => console.log('add', n))sub.watch(n => console.log('subtract', n))reset.watch(() => console.log('reset counter'))
add(5)// add 5// counter: 5sub(1)// subtract 1// counter: 4reset()// reset counter// counter: 0
Type safe
TypeScript and Flow support out of box.
Framework agnostic
Can work with any UI or server framework.
Developer-friendly
Simple API surface and helpful community.
Maximum performance
Static initialization provides boost in performance for runtime.
Tiny bundle size
Effector uses Rollup and Terser to provide small builds.
Plain javascript
No decorators, no proxies, no classes required. Only you and your data.