MCPcopy Index your code
hub / github.com/Effect-TS/effect / ask

Method ask

packages/effect/src/internal/fiberRuntime.ts:426–438  ·  view source on GitHub ↗

* Returns an effect that will contain information computed from the fiber * state and status while running on the fiber. * * This allows the outside world to interact safely with mutable fiber state * without locks or immutable data.

(
    f: (runtime: FiberRuntime<any, any>, status: FiberStatus.FiberStatus) => Z
  )

Source from the content-addressed store, hash-verified

424 * without locks or immutable data.
425 */
426 ask<Z>(
427 f: (runtime: FiberRuntime<any, any>, status: FiberStatus.FiberStatus) => Z
428 ): Effect.Effect<Z> {
429 return core.suspend(() => {
430 const deferred = core.deferredUnsafeMake<Z>(this._fiberId)
431 this.tell(
432 FiberMessage.stateful((fiber, status) => {
433 core.deferredUnsafeDone(deferred, core.sync(() => f(fiber, status)))
434 })
435 )
436 return core.deferredAwait(deferred)
437 })
438 }
439
440 /**
441 * Adds a message to be processed by the fiber on the fiber.

Callers 4

statusMethod · 0.95
runtimeFlagsMethod · 0.95
childrenMethod · 0.95
fiberRefsMethod · 0.95

Calls 3

tellMethod · 0.95
syncMethod · 0.80
fFunction · 0.50

Tested by

no test coverage detected