Asosiy tarkibga o'tish


scopeBind<T>(event: Event<T>): (payload: T) => void

A method to bind event or effect to a scope to be called later. effector supports imperative event calling inside watchers, but sometimes you should bind events to the scope explicitly, e.g. when calling events within a setTimeout/setInterval callbacks.


  1. event Event to be bound to the scope


We are going to call changeLocation inside history.listen callback so there is no way for effector to associate event with corresponding scope, and we should explicitly bind event to scope using scopeBind

const installHistory = app.createEvent<any>()
const changeLocation = app.createEvent<string>() => {

const locationUpdate = scopeBind(changeLocation)
history.listen(location => {

See full example