Minor Changes
-
#3048
a1f5b83
Thanks @tim-smart! - add renderErrorCause option to Cause.pretty -
#3048
60bc3d0
Thanks @tim-smart! - add RcRef moduleAn
RcRef
wraps a reference counted resource that can be acquired and released multiple times.The resource is lazily acquired on the first call to
get
and released when the last reference is released.import { Effect, RcRef } from "effect"; Effect.gen(function* () { const ref = yield* RcRef.make({ acquire: Effect.acquireRelease(Effect.succeed("foo"), () => Effect.log("release foo"), ), }); // will only acquire the resource once, and release it // when the scope is closed yield* RcRef.get(ref).pipe(Effect.andThen(RcRef.get(ref)), Effect.scoped); });
-
#3048
5ab348f
Thanks @tim-smart! - allowing customizing Stream pubsub strategyimport { Schedule, Stream } from "effect"; // toPubSub Stream.fromSchedule(Schedule.spaced(1000)).pipe( Stream.toPubSub({ capacity: 16, // or "unbounded" strategy: "dropping", // or "sliding" / "suspend" }), ); // also for the broadcast apis Stream.fromSchedule(Schedule.spaced(1000)).pipe( Stream.broadcastDynamic({ capacity: 16, strategy: "dropping", }), );
-
#3048
60bc3d0
Thanks @tim-smart! - add Duration.isZero, for checking if a Duration is zero -
#3048
3e04bf8
Thanks @sukovanej! - AddSuccess
type util forConfig
. -
#3048
e7fc45f
Thanks @tim-smart! - add Logger.prettyLogger and Logger.prettyLogger.pretty
is a new logger that leverages the features of theconsole
APIs to provide a more visually appealing output.To try it out, provide it to your program:
import { Effect, Logger } from "effect"; Effect.log("Hello, World!").pipe(Effect.provide(Logger.pretty));
-
#3048
a1f5b83
Thanks @tim-smart! - add .groupCollapsed to UnsafeConsole -
#3048
4626de5
Thanks @giacomoran! - export Random.make taking hashable values as seed -
#3048
f01e7db
Thanks @tim-smart! - addreplay
option to PubSub constructorsThis option adds a replay buffer in front of the given PubSub. The buffer will
replay the lastn
messages to any new subscriber.Effect.gen(function*() { const messages = [1, 2, 3, 4, 5] const pubsub = yield* PubSub.bounded<number>({ capacity: 16, replay: 3 }) yield* PubSub.publishAll(pubsub, messages) const sub = yield* PubSub.subscribe(pubsub) assert.deepStrictEqual(Chunk.toReadonlyArray(yield* Queue.takeAll(sub)), [3, 4, 5]) }))
-
#3048
60bc3d0
Thanks @tim-smart! - add RcMap moduleAn
RcMap
can contain multiple reference counted resources that can be indexed
by a key. The resources are lazily acquired on the first call toget
and
released when the last reference is released.Complex keys can extend
Equal
andHash
to allow lookups by value.import { Effect, RcMap } from "effect"; Effect.gen(function* () { const map = yield* RcMap.make({ lookup: (key: string) => Effect.acquireRelease(Effect.succeed(`acquired ${key}`), () => Effect.log(`releasing ${key}`), ), }); // Get "foo" from the map twice, which will only acquire it once // It will then be released once the scope closes. yield* RcMap.get(map, "foo").pipe( Effect.andThen(RcMap.get(map, "foo")), Effect.scoped, ); });
-
#3048
ac71f37
Thanks @dilame! - EnsureScope
is excluded fromR
in theChannel
/Stream
run*
functions.This fix ensures that
Scope
is now properly excluded from the resulting effect environment.
The affected functions includerun
,runCollect
,runCount
,runDrain
and other non-scopedrun*
in bothStream
andChannel
modules.
This fix brings the type declaration in line with the runtime implementation. -
#3048
8432360
Thanks @dilame! - refactor(Stream/mergeLeft): renameself
/that
argument names toleft
/right
for clarityrefactor(Stream/mergeRight): rename
self
/that
argument names toleft
/right
for clarity -
#3048
e4bf1bf
Thanks @dilame! - feat(Stream): implement "raceAll" operator, which returns a stream that mirrors the first source stream to emit an item.import { Stream, Schedule, Console, Effect } from "effect"; const stream = Stream.raceAll( Stream.fromSchedule(Schedule.spaced("1 millis")), Stream.fromSchedule(Schedule.spaced("2 millis")), Stream.fromSchedule(Schedule.spaced("4 millis")), ).pipe(Stream.take(6), Stream.tap(Console.log)); Effect.runPromise(Stream.runDrain(stream)); // Output only from the first stream, the rest streams are interrupted // 0 // 1 // 2 // 3 // 4 // 5
-
#3048
13cb861
Thanks @dilame! - refactor(Stream): use new built-inTypes.TupleOf
instead ofStream.DynamicTuple
and deprecate it -
#3048
79d2d91
Thanks @tim-smart! - support ErrorOptions in YieldableError constructor -
#3048
9f66825
Thanks @tim-smart! - allow customizing the output buffer for the Stream.async* apisimport { Stream } from "effect"; Stream.async<string>( (emit) => { // ... }, { bufferSize: 16, strategy: "dropping", // you can also use "sliding" or "suspend" }, );
Patch Changes
-
#3048
a1f5b83
Thanks @tim-smart! - include Error.cause stack in log output -
#3048
a1f5b83
Thanks @tim-smart! - set stackTraceLimit to 1 in PrettyError to address performance issues -
#3048
79d2d91
Thanks @tim-smart! - ensure "cause" is rendered in Data.Error output -
#3048
e7fc45f
Thanks @tim-smart! - fix types of UnsafeConsole.group