Update docs
Lint / lint (push) Failing after 11s

This commit is contained in:
Julien Valverdé
2026-05-30 05:46:48 +02:00
parent 188ccc20d2
commit aad84f9ba9
+10 -3
View File
@@ -28,7 +28,7 @@ Lens<
A, // Type of the value the lens is focused on
ER, // Errors that can happen when reading
EW, // Errors that can happen when writing
RE, // Requirements for reading
RR, // Requirements for reading
RW // Requirements for writing
>
```
@@ -55,11 +55,16 @@ yield* Lens.update(lens, Array.replace(1, 1664))
Currently available:
- `fromSubscriptionRef`
- `fromSynchronizedRef` (note: since `SynchronizedRef` is not reactive (does not produce a stream of value changes), the resulting Lens' `changes` stream will only emit the current value of the lens when evaluated, and nothing else)
- `fromRef` (returns an effect because it creates an internal lock)
More to come!
#### Manually
You can also create Lenses manually using `make` by providing a getter, a stream of changes and either a `set` or `modify` function depending on your needs.
You can also create Lenses manually using `make` by providing:
- `get`: an effect that reads the current value,
- `changes`: a stream of value changes,
- `commit`: an effectful write primitive,
- `lock`: an effect that produces the lock used to serialize writes.
You can get pretty creative! Here's an example of a Lens that points to a specific key of the browser `LocalStorage`:
```typescript
@@ -83,9 +88,11 @@ const lens = Effect.all([
Stream.unwrap,
),
set: a => Option.isSome(a)
commit: a => Option.isSome(a)
? kv.set(key, a.value)
: kv.remove(key),
lock: Effect.succeed(effect => effect),
})),
Effect.provide(BrowserKeyValueStore.layerLocalStorage),