Skip to content

Effect 3.3 (Release)

Effect 3.3.0 has been released! This release includes a number of new features and improvements. Here’s a summary of what’s new:

This api can be used to zip multiple streams together. When a value is emitted by any of the streams, it is combined with the latest values from the other streams to produce a result.

1
import { Stream, Schedule, Console, Effect } from "effect"
2
3
const stream = Stream.zipLatestAll(
4
Stream.fromSchedule(Schedule.spaced("1 millis")),
5
Stream.fromSchedule(Schedule.spaced("2 millis")),
6
Stream.fromSchedule(Schedule.spaced("4 millis"))
7
).pipe(Stream.take(6), Stream.tap(Console.log))
8
9
Effect.runPromise(Stream.runDrain(stream))
10
// Output:
11
// [ 0, 0, 0 ]
12
// [ 1, 0, 0 ]
13
// [ 1, 1, 0 ]
14
// [ 2, 1, 0 ]
15
// [ 3, 1, 0 ]
16
// [ 3, 1, 1 ]
17
// .....

This option is passed to the underlying ReadableStream constructor. It allows you to control the backpressure strategy of the stream.

See MDN for more information.

New concurrency & resizing options have been added to the Pool constructors, as well as some performance improvements.

You can now specify the concurrent access per pool item. This is useful when you have a pool item that can handle multiple concurrent requests.

This option determines when new pool items are created. It is a value between 0 and 1, where 1 means only create new pool items when all the existing items are fully utilized.

A targetUtilization of 0.5 will create new pool items when the existing items are 50% utilized.

By default it is set to 1,

This option allows you to specify a strategy that determines how the pool is resized. The default strategy is "usage", which invalidates pool items based on the targetUtilization.

Another strategy is "creation", which invalidates pool items based on the time they were created.

The value to bind to this can be passed as the first argument to the .gen function.

1
import { Option } from "effect"
2
3
class MyClass {
4
readonly value = 1
5
6
readonly option = Option.gen(this, function* () {
7
// you can now access `this.value`
8
})
9
}

The Redacted<T> data type represents sensitive data. It is generic, so it can be used to redact any type of data.

Support for Redacted has been added to @effect/schema & @effect/cli.

The Secret module has now been marked as deprecated, and will be removed in a future release.

This api will annotate any logs emitted during the execution of the layer. Fibers that are forked from the layer will also have their logs annotated.

Similar to Layer.annotateLogs, but for tracing spans.

If you pass a URL object to the ClientRequest constructors, it will now also populate the url parameters & hash of the request.

1
// create a request to https://example.com/foo?foo=bar&baz=qux#hash
2
Http.request
3
.get(new URL("https://example.com/?foo=bar#hash"))
4
.pipe(
5
Http.request.appendUrl("/foo"),
6
Http.request.setUrlParam("baz", "qux")
7
)

The following type guards have been added to the Predicate module:

  • isTupleOf - a refinement that checks if a value is a tuple of a specific length
  • isTupleOfAtLeast - a refinement that checks if a value is a tuple at least the specified length

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!