Effector

Effector

  • Docs
  • Try
  • API
  • Blog
  • GitHub

›effector

effector

  • API Reference
  • Event
  • Store
  • Effect
  • Domain
  • createStore
  • createEvent
  • createEffect
  • createDomain
  • createStoreObject
  • combine
  • restore
  • createApi
  • clearNode
  • merge
  • split
  • sample
  • guard
  • forward
  • fromObservable

effector-react

  • API Reference
  • useStore
  • useStoreMap
  • useList
  • createComponent
  • Gate
  • createGate
  • useGate
  • createStoreConsumer

effector-vue

  • API Reference
  • VueEffector
  • ComponentOptions
  • Vue
Edit

createApi(store, api)

createApi is a short-hand for creating events attached to store

Arguments

  1. store (Store)
  2. api (Object)

Returns

(Object)

Example

// Create store
const playerPosition = createStore({x: 0, y: 0}) // <-- Default state

// Attach events to store and create them
const api = createApi(playerPosition, {
  moveLeft: ({x, y}, n) => ({x, y: y + n}),
  moveRight: ({x, y}, n) => ({x, y: y - n}),
})

api.moveLeft(10)
api.moveRight(5)
← restoreclearNode →
Effector
Docs
Getting StartedAPI Reference
Community
User ShowcaseStack OverflowGitterTwitter
More
GitHubStar
Copyright © 2019 zerobias