@@ -1,20 +1,20 @@
|
||||
import { type Cause, Context, Effect, Exit, Layer, Option, Pipeable, Predicate, PubSub, type Queue, type Scope, Supervisor } from "effect"
|
||||
|
||||
|
||||
export const TypeId: unique symbol = Symbol.for("@effect-fc/ErrorObserver/ErrorObserver")
|
||||
export type TypeId = typeof TypeId
|
||||
export const ErrorObserverTypeId: unique symbol = Symbol.for("@effect-fc/ErrorObserver/ErrorObserver")
|
||||
export type ErrorObserverTypeId = typeof ErrorObserverTypeId
|
||||
|
||||
export interface ErrorObserver<in out E = never> extends Pipeable.Pipeable {
|
||||
readonly [TypeId]: TypeId
|
||||
readonly [ErrorObserverTypeId]: ErrorObserverTypeId
|
||||
handle<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
|
||||
readonly subscribe: Effect.Effect<Queue.Dequeue<Cause.Cause<E>>, never, Scope.Scope>
|
||||
}
|
||||
|
||||
export const ErrorObserver = <E = never>(): Context.Tag<ErrorObserver, ErrorObserver<E>> => Context.GenericTag("@effect-fc/ErrorObserver/ErrorObserver")
|
||||
|
||||
class ErrorObserverImpl<in out E = never>
|
||||
export class ErrorObserverImpl<in out E = never>
|
||||
extends Pipeable.Class() implements ErrorObserver<E> {
|
||||
readonly [TypeId]: TypeId = TypeId
|
||||
readonly [ErrorObserverTypeId]: ErrorObserverTypeId = ErrorObserverTypeId
|
||||
readonly subscribe: Effect.Effect<Queue.Dequeue<Cause.Cause<E>>, never, Scope.Scope>
|
||||
|
||||
constructor(
|
||||
@@ -29,7 +29,7 @@ extends Pipeable.Class() implements ErrorObserver<E> {
|
||||
}
|
||||
}
|
||||
|
||||
class ErrorObserverSupervisorImpl extends Supervisor.AbstractSupervisor<void> {
|
||||
export class ErrorObserverSupervisorImpl extends Supervisor.AbstractSupervisor<void> {
|
||||
readonly value = Effect.void
|
||||
constructor(readonly pubsub: PubSub.PubSub<Cause.Cause<never>>) {
|
||||
super()
|
||||
@@ -43,7 +43,7 @@ class ErrorObserverSupervisorImpl extends Supervisor.AbstractSupervisor<void> {
|
||||
}
|
||||
|
||||
|
||||
export const isErrorObserver = (u: unknown): u is ErrorObserver<unknown> => Predicate.hasProperty(u, TypeId)
|
||||
export const isErrorObserver = (u: unknown): u is ErrorObserver<unknown> => Predicate.hasProperty(u, ErrorObserverTypeId)
|
||||
|
||||
export const layer: Layer.Layer<ErrorObserver> = Layer.unwrapEffect(Effect.map(
|
||||
PubSub.unbounded<Cause.Cause<never>>(),
|
||||
|
||||
Reference in New Issue
Block a user