Effect 3.8 has been released! This release includes a number of new features
and improvements. Here’s a summary of what’s new:
Logger.withLeveledConsole
With this api you can create a logger that uses the console.{log,info,warn,error,trace} functions,
depending on the log level of each message.
This is useful in environments such as browsers, where the different log levels are styled differently.
For example:
More types implement Effect
Many of the data types in Effect can now be used directly as Effect’s.
These include:
Ref<A> - Effect<A>, equivalent to Ref.get
SynchronizedRef<A> - Effect<A>, equivalent to SynchronizedRef.get
SubscriptionRef<A> - Effect<A>, equivalent to SubscriptionRef.get
Deferred<A, E> - Effect<A, E>, equivalent to Deferred.await
Dequeue<A> - Effect<A>, equivalent to Queue.take
Fiber<A, E> - Effect<A, E>, equivalent to Fiber.join
FiberRef<A> - Effect<A>, equivalent to FiberRef.get
Semaphore.withPermitsIfAvailable
Semaphore.withPermitsIfAvailable will attempt to run an effect immediately if permits are available.
It will return an Option<A> from the result of the effect, depending on whether the permits were available.
Effect.makeLatch
You can create an Effect.Latch with Effect.makeLatch, which can be used to synchronize multiple effects.
The latch can be opened, closed and waited on.
Stream.share
Stream.share is a reference counted equivalent of the Stream.broadcastDynamic api.
It is useful when you want to share a Stream, and ensure any resources are finalized when no more consumers are subscribed.
HttpClient refactor
The @effect/platform/HttpClient module has been refactored to reduce and simplify the api surface.
HttpClient.fetch removed
The HttpClient.fetch client implementation has been removed. Instead, you can
access a HttpClient using the corresponding Context.Tag.
HttpClient interface now uses methods
Instead of being a function that returns the response, the HttpClient
interface now uses methods to make requests.
Some shorthand methods have been added to the HttpClient interface to make
less complex requests easier to implement.
Scoped HttpClientResponse helpers removed
The HttpClientResponse helpers that also supplied the Scope have been removed.
Instead, you can use the HttpClientResponse methods directly, and explicitly
add a Effect.scoped to the pipeline.
Some apis have been renamed
Including the HttpClientRequest body apis, which is to make them more
discoverable.
Mailbox module
A new experimental effect/Mailbox module has been added. Mailbox is an asynchronous queue
that can have a done / failure signal.
It is useful when you want to communicate between effects, and have a way to determine that
the communication is complete.
FiberRef performance improvements
Some common FiberRef instances are now cached, which improves performance of the Effect runtime.
RcMap.keys & MutableMap.keys
You can now access the available keys of a RcMap or MutableMap using the keys api.
For example:
And for RcMap:
Duration conversion apis
Some new apis for converting between a Duration and it’s corresponding parts have been added:
Duration.toMinutes
Duration.toHours
Duration.toDays
Duration.toWeeks
Duration.parts
Other changes
There were several other smaller changes made. Take a look through the CHANGELOG to see them all: CHANGELOG.
Don’t forget to join our Discord Community to follow the last updates and discuss every tiny detail!