MCPcopy
hub / github.com/statelyai/xstate / toObserver

Function toObserver

packages/core/src/utils.ts:234–249  ·  view source on GitHub ↗
(
  nextHandler?: Observer<T> | ((value: T) => void),
  errorHandler?: (error: any) => void,
  completionHandler?: () => void
)

Source from the content-addressed store, hash-verified

232}
233
234export function toObserver<T>(
235 nextHandler?: Observer<T> | ((value: T) => void),
236 errorHandler?: (error: any) => void,
237 completionHandler?: () => void
238): Observer<T> {
239 const isObserver = typeof nextHandler === 'object';
240 const self = isObserver ? nextHandler : undefined;
241
242 return {
243 next: (isObserver ? nextHandler.next : nextHandler)?.bind(self),
244 error: (isObserver ? nextHandler.error : errorHandler)?.bind(self),
245 complete: (isObserver ? nextHandler.complete : completionHandler)?.bind(
246 self
247 )
248 };
249}
250
251export function createInvokeId(stateNodeId: string, index: number): string {
252 return `${index}.${stateNodeId}`;

Callers 8

constructorMethod · 0.90
subscribeMethod · 0.90
selectMethod · 0.90
createSystemFunction · 0.90
useActorRefFunction · 0.85
inspectFunction · 0.85
subscribeFunction · 0.85
useActorRefFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected