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

A helper to call events within a scope (see fork). 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

Last updated on