MCPcopy Create free account
hub / github.com/Effect-TS/effect / evaluate

Method evaluate

packages/effect/src/internal/effect.ts:598–627  ·  view source on GitHub ↗
(effect: Primitive)

Source from the content-addressed store, hash-verified

596 return this._exit
597 }
598 evaluate(effect: Primitive): void {
599 if (this._exit) {
600 return
601 } else if (this._yielded !== undefined) {
602 const yielded = this._yielded as () => void
603 this._yielded = undefined
604 yielded()
605 }
606 const exit = this.runLoop(effect)
607 if (exit === Yield) {
608 return
609 }
610 // the interruptChildren middleware is added in Effect.forkChild, so it can be
611 // tree-shaken if not used
612 const interruptChildren = fiberMiddleware.interruptChildren &&
613 fiberMiddleware.interruptChildren(this)
614 if (interruptChildren !== undefined) {
615 return this.evaluate(flatMap(interruptChildren, () => exit) as any)
616 }
617
618 this._exit = exit
619 this.runtimeMetrics?.recordFiberEnd(this.context, this._exit)
620 for (let i = 0; i < this._observers.length; i++) {
621 this._observers[i](exit)
622 }
623 this._observers.length = 0
624 this._stack.length = 0
625 this._children = undefined
626 this.context = Context.empty()
627 }
628 runLoop(effect: Primitive): Exit.Exit<A, E> | Yield {
629 const prevFiber = (globalThis as any)[currentFiberTypeId]
630 ;(globalThis as any)[currentFiberTypeId] = this

Callers 1

interruptUnsafeMethod · 0.95

Calls 1

runLoopMethod · 0.95

Tested by

no test coverage detected