Add Effect v4 support, Fast Refresh tooling, and revamped docs #56

Merged
Thilawyn merged 133 commits from next into master 2026-07-26 02:32:59 +02:00
3 changed files with 0 additions and 52 deletions
Showing only changes of commit 3533fa0c84 - Show all commits
-4
View File
@@ -25,10 +25,6 @@
"types": "./dist/Component.d.ts", "types": "./dist/Component.d.ts",
"default": "./dist/Component.js" "default": "./dist/Component.js"
}, },
"./ErrorObserver": {
"types": "./dist/ErrorObserver.d.ts",
"default": "./dist/ErrorObserver.js"
},
"./Form": { "./Form": {
"types": "./dist/Form.d.ts", "types": "./dist/Form.d.ts",
"default": "./dist/Form.js" "default": "./dist/Form.js"
@@ -1,47 +0,0 @@
import { type Cause, Context, Effect, Layer, Option, Pipeable, Predicate, PubSub, type Scope } from "effect"
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 [ErrorObserverTypeId]: ErrorObserverTypeId
handle<A, E1, R>(effect: Effect.Effect<A, E1, R>): Effect.Effect<A, E1, R>
readonly subscribe: Effect.Effect<PubSub.Subscription<Cause.Cause<E>>, never, Scope.Scope>
}
export const ErrorObserver = <E = never>() => Context.Service<ErrorObserver<E>>(
"@effect-fc/ErrorObserver/ErrorObserver",
)
export class ErrorObserverImpl<in out E = never> extends Pipeable.Class implements ErrorObserver<E> {
readonly [ErrorObserverTypeId]: ErrorObserverTypeId = ErrorObserverTypeId
constructor(readonly pubsub: PubSub.PubSub<Cause.Cause<E>>) {
super()
}
get subscribe(): Effect.Effect<PubSub.Subscription<Cause.Cause<E>>, never, Scope.Scope> {
return PubSub.subscribe(this.pubsub)
}
handle<A, E1, R>(effect: Effect.Effect<A, E1, R>): Effect.Effect<A, E1, R> {
return Effect.tapCause(effect, cause => Effect.asVoid(
PubSub.publish(this.pubsub, cause as unknown as Cause.Cause<E>),
))
}
}
export const isErrorObserver = (u: unknown): u is ErrorObserver<unknown> => Predicate.hasProperty(u, ErrorObserverTypeId)
export const layer: Layer.Layer<ErrorObserver> = Layer.effect(ErrorObserver())(
Effect.map(PubSub.unbounded<Cause.Cause<never>>(), pubsub => new ErrorObserverImpl(pubsub)),
)
export const handle = <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> => Effect.flatMap(
Effect.serviceOption(ErrorObserver()),
Option.match({
onSome: observer => observer.handle(effect),
onNone: () => effect,
}),
)
-1
View File
@@ -1,6 +1,5 @@
export * as Async from "./Async.js" export * as Async from "./Async.js"
export * as Component from "./Component.js" export * as Component from "./Component.js"
export * as ErrorObserver from "./ErrorObserver.js"
export * as Form from "./Form.js" export * as Form from "./Form.js"
export * as Lens from "./Lens.js" export * as Lens from "./Lens.js"
export * as LensForm from "./LensForm.js" export * as LensForm from "./LensForm.js"