@effect-atom/atom 0.4.10 → 0.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/Atom.ts CHANGED
@@ -40,17 +40,8 @@ import * as Registry from "./Registry.js"
40
40
  import { AtomRegistry as AtomRegistry } from "./Registry.js"
41
41
  import * as Result from "./Result.js"
42
42
 
43
- /**
44
- * @since 1.0.0
45
- * @category type ids
46
- */
47
- export const TypeId: TypeId = "~effect-atom/atom/Atom"
48
-
49
- /**
50
- * @since 1.0.0
51
- * @category type ids
52
- */
53
- export type TypeId = "~effect-atom/atom/Atom"
43
+ const TypeId: TypeId = "~effect-atom/atom/Atom"
44
+ type TypeId = "~effect-atom/atom/Atom"
54
45
 
55
46
  /**
56
47
  * @since 1.0.0
@@ -98,17 +89,8 @@ export type Failure<T extends Atom<any>> = T extends Atom<Result.Result<infer _,
98
89
  export type WithoutSerializable<T extends Atom<any>> = T extends Writable<infer R, infer W> ? Writable<R, W>
99
90
  : Atom<Type<T>>
100
91
 
101
- /**
102
- * @since 1.0.0
103
- * @category type ids
104
- */
105
- export const WritableTypeId: WritableTypeId = "~effect-atom/atom/Atom/Writable"
106
-
107
- /**
108
- * @since 1.0.0
109
- * @category type ids
110
- */
111
- export type WritableTypeId = "~effect-atom/atom/Atom/Writable"
92
+ type WritableTypeId = "~effect-atom/atom/Atom/Writable"
93
+ const WritableTypeId: WritableTypeId = "~effect-atom/atom/Atom/Writable"
112
94
 
113
95
  /**
114
96
  * @since 1.0.0
@@ -1826,7 +1808,13 @@ export const kvs = <A>(options: {
1826
1808
  return writable(
1827
1809
  (get) => {
1828
1810
  get.mount(setAtom)
1829
- return Result.getOrElse(get(resultAtom), options.defaultValue)
1811
+ const value = Result.value(get(resultAtom))
1812
+ if (Option.isSome(value)) {
1813
+ return value.value
1814
+ }
1815
+ const defaultValue = options.defaultValue()
1816
+ get.set(setAtom, defaultValue)
1817
+ return defaultValue
1830
1818
  },
1831
1819
  (ctx, value: A) => {
1832
1820
  ctx.set(setAtom, value as any)
package/src/AtomRef.ts CHANGED
@@ -5,17 +5,8 @@ import * as Equal from "effect/Equal"
5
5
  import { globalValue } from "effect/GlobalValue"
6
6
  import * as Hash from "effect/Hash"
7
7
 
8
- /**
9
- * @since 1.0.0
10
- * @category type ids
11
- */
12
- export const TypeId: TypeId = "~effect-atom/atom/AtomRef"
13
-
14
- /**
15
- * @since 1.0.0
16
- * @category type ids
17
- */
18
- export type TypeId = "~effect-atom/atom/AtomRef"
8
+ const TypeId: TypeId = "~effect-atom/atom/AtomRef"
9
+ type TypeId = "~effect-atom/atom/AtomRef"
19
10
 
20
11
  /**
21
12
  * @since 1.0.0
package/src/Registry.ts CHANGED
@@ -15,17 +15,8 @@ import type { Registry } from "./index.js"
15
15
  import * as internal from "./internal/registry.js"
16
16
  import * as Result from "./Result.js"
17
17
 
18
- /**
19
- * @since 1.0.0
20
- * @category type ids
21
- */
22
- export const TypeId: TypeId = "~effect-atom/atom/Registry"
23
-
24
- /**
25
- * @since 1.0.0
26
- * @category type ids
27
- */
28
- export type TypeId = "~effect-atom/atom/Registry"
18
+ const TypeId: TypeId = "~effect-atom/atom/Registry"
19
+ type TypeId = "~effect-atom/atom/Registry"
29
20
 
30
21
  /**
31
22
  * @since 1.0.0
package/src/Result.ts CHANGED
@@ -15,17 +15,8 @@ import { hasProperty, isIterable } from "effect/Predicate"
15
15
  import * as Schema_ from "effect/Schema"
16
16
  import type * as Types from "effect/Types"
17
17
 
18
- /**
19
- * @since 1.0.0
20
- * @category type ids
21
- */
22
- export const TypeId = Symbol.for("@effect-atom/atom/Result")
23
-
24
- /**
25
- * @since 1.0.0
26
- * @category type ids
27
- */
28
- export type TypeId = typeof TypeId
18
+ type TypeId = "~effect-atom/atom/Result"
19
+ const TypeId: TypeId = "~effect-atom/atom/Result"
29
20
 
30
21
  /**
31
22
  * @since 1.0.0
@@ -12,8 +12,8 @@ import * as Result from "../Result.js"
12
12
 
13
13
  const constImmediate = { immediate: true }
14
14
 
15
- /** @internal */
16
- export const TypeId: Registry.TypeId = "~effect-atom/atom/Registry"
15
+ type TypeId = "~effect-atom/atom/Registry"
16
+ const TypeId: TypeId = "~effect-atom/atom/Registry" as const
17
17
 
18
18
  /** @internal */
19
19
  export const make = (options?: {
@@ -34,7 +34,7 @@ const atomKey = <A>(atom: Atom.Atom<A>): Atom.Atom<A> | string =>
34
34
  SerializableTypeId in atom ? (atom as Atom.Serializable<any>)[SerializableTypeId].key : atom
35
35
 
36
36
  class RegistryImpl implements Registry.Registry {
37
- readonly [TypeId]: Registry.TypeId
37
+ readonly [TypeId]: TypeId
38
38
  readonly timeoutResolution: number
39
39
 
40
40
  constructor(