MCPcopy Index your code
hub / github.com/effector/effector / on

Function on

src/effector/createUnit.ts:227–247  ·  view source on GitHub ↗
(
  store: Store<State>,
  methodName: string,
  nodeSet: CommonUnit | CommonUnit[],
  fn: Function,
  errorTitle: string,
)

Source from the content-addressed store, hash-verified

225 return finalEvent
226}
227function on<State>(
228 store: Store<State>,
229 methodName: string,
230 nodeSet: CommonUnit | CommonUnit[],
231 fn: Function,
232 errorTitle: string,
233) {
234 assertNodeSet(nodeSet, `${errorTitle} ${methodName}`, 'first argument')
235 assert(isFunction(fn), 'second argument should be a function', errorTitle)
236 deprecate(
237 !getMeta(store, 'derived'),
238 `${methodName} in derived store`,
239 `${methodName} in store created via createStore`,
240 errorTitle,
241 )
242 forEach(Array.isArray(nodeSet) ? nodeSet : [nodeSet], trigger => {
243 store.off(trigger)
244 updateStore(trigger, store, 'on', callARegStack, fn)
245 })
246 return store
247}
248
249export const requireExplicitSkipVoidMessage =
250 'undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option'

Callers 1

resetFunction · 0.85

Calls 8

assertNodeSetFunction · 0.90
assertFunction · 0.90
isFunctionFunction · 0.90
deprecateFunction · 0.90
getMetaFunction · 0.90
forEachFunction · 0.90
updateStoreFunction · 0.85
offMethod · 0.65

Tested by

no test coverage detected