Skip to content

Commit f8f6dfa

Browse files
committed
fix Rx.kvs
1 parent 35045bf commit f8f6dfa

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

.changeset/smart-lies-drop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect-rx/rx": patch
3+
---
4+
5+
fix Rx.kvs

packages/rx/src/Rx.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,19 +1305,16 @@ export const kvs = <A>(options: {
13051305
})
13061306
)
13071307
const resultRx = options.runtime.rx(
1308-
Effect.fnUntraced(function*(get: Context) {
1309-
const store = (yield* KeyValueStore.KeyValueStore).forSchema(
1310-
options.schema
1311-
)
1312-
get.mount(setRx)
1313-
return Option.getOrElse(
1314-
yield* store.get(options.key),
1315-
options.defaultValue
1316-
)
1317-
})
1308+
Effect.flatMap(
1309+
KeyValueStore.KeyValueStore,
1310+
(store) => Effect.flatten(store.forSchema(options.schema).get(options.key))
1311+
)
13181312
)
13191313
return writable(
1320-
(get) => Result.getOrElse(resultRx.read(get), options.defaultValue),
1314+
(get) => {
1315+
get.mount(setRx)
1316+
return Result.getOrElse(get(resultRx), options.defaultValue)
1317+
},
13211318
(ctx, value: A) => {
13221319
ctx.set(setRx, value as any)
13231320
ctx.setSelf(value)

0 commit comments

Comments
 (0)