how to runFiber in effectcore

how to "runFiber" in @effect/core?
trying to convert a dumbed down version of effect-ts/node's runMain:
export function runMain<E, A>(eff: Effect<never, E, A>) {
  const context = eff.runFiber()

  const onExit = (s: number) => {
    process.exit(s)
  }

  context.runAsync((exit) => {
    switch (exit._tag) {
      case "Failure": {
        if (Cause.interruptedOnly(exit.cause)) {
          defaultTeardown(0, context.id, onExit)
          break
        } else {
          console.error(JSON.stringify(exit.cause, undefined, 2))
          defaultTeardown(1, context.id, onExit)
          break
        }
      }
      case "Success": {
        defaultTeardown(0, context.id, onExit)
        break
      }
    }
  })

  function handler() {
    process.removeListener("SIGTERM", handler)
    process.removeListener("SIGINT", handler)
    context.interruptAs(context.id).unsafeRunAsync()
  }
  process.once("SIGTERM", handler)
  process.once("SIGINT", handler)
}
Was this page helpful?