createApi(store, api)
createApi
is a shorthand for creating events attached to store
Arguments
Returns
(Object
) Object with events
Example
import {createStore, createApi} from 'effector'
const playerPosition = createStore(0)
// create events and attach them to storeconst api = createApi(playerPosition, { moveLeft: (pos, n) => pos - n, moveRight: (pos, n) => pos + n,})
playerPosition.watch(pos => { console.log('position', pos)})// => position 0
api.moveRight(10)// => position 10api.moveLeft(5)// => position 5