effect 4.0.0-beta.17 → 4.0.0-beta.19

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.
Files changed (164) hide show
  1. package/dist/Array.d.ts +127 -299
  2. package/dist/Array.d.ts.map +1 -1
  3. package/dist/Array.js +102 -62
  4. package/dist/Array.js.map +1 -1
  5. package/dist/Cache.d.ts.map +1 -1
  6. package/dist/Cache.js +5 -4
  7. package/dist/Cache.js.map +1 -1
  8. package/dist/Channel.d.ts +97 -11
  9. package/dist/Channel.d.ts.map +1 -1
  10. package/dist/Channel.js +72 -29
  11. package/dist/Channel.js.map +1 -1
  12. package/dist/Chunk.d.ts +54 -247
  13. package/dist/Chunk.d.ts.map +1 -1
  14. package/dist/Chunk.js +36 -67
  15. package/dist/Chunk.js.map +1 -1
  16. package/dist/Effect.d.ts +337 -437
  17. package/dist/Effect.d.ts.map +1 -1
  18. package/dist/Effect.js +118 -134
  19. package/dist/Effect.js.map +1 -1
  20. package/dist/Filter.d.ts +0 -33
  21. package/dist/Filter.d.ts.map +1 -1
  22. package/dist/Filter.js +0 -13
  23. package/dist/Filter.js.map +1 -1
  24. package/dist/HashMap.d.ts +15 -14
  25. package/dist/HashMap.d.ts.map +1 -1
  26. package/dist/HashMap.js +4 -4
  27. package/dist/HashMap.js.map +1 -1
  28. package/dist/Iterable.d.ts +40 -39
  29. package/dist/Iterable.d.ts.map +1 -1
  30. package/dist/Iterable.js +94 -22
  31. package/dist/Iterable.js.map +1 -1
  32. package/dist/Option.d.ts +22 -15
  33. package/dist/Option.d.ts.map +1 -1
  34. package/dist/Option.js +14 -7
  35. package/dist/Option.js.map +1 -1
  36. package/dist/Pull.d.ts.map +1 -1
  37. package/dist/Pull.js +1 -1
  38. package/dist/Pull.js.map +1 -1
  39. package/dist/Record.d.ts +24 -120
  40. package/dist/Record.d.ts.map +1 -1
  41. package/dist/Record.js +21 -41
  42. package/dist/Record.js.map +1 -1
  43. package/dist/Sink.d.ts +11 -11
  44. package/dist/Sink.d.ts.map +1 -1
  45. package/dist/Sink.js +53 -6
  46. package/dist/Sink.js.map +1 -1
  47. package/dist/Stream.d.ts +198 -386
  48. package/dist/Stream.d.ts.map +1 -1
  49. package/dist/Stream.js +103 -59
  50. package/dist/Stream.js.map +1 -1
  51. package/dist/Trie.d.ts +18 -17
  52. package/dist/Trie.d.ts.map +1 -1
  53. package/dist/Trie.js +5 -5
  54. package/dist/Trie.js.map +1 -1
  55. package/dist/TxChunk.d.ts +37 -37
  56. package/dist/TxChunk.d.ts.map +1 -1
  57. package/dist/TxChunk.js +3 -3
  58. package/dist/TxChunk.js.map +1 -1
  59. package/dist/TxDeferred.d.ts +328 -0
  60. package/dist/TxDeferred.d.ts.map +1 -0
  61. package/dist/TxDeferred.js +196 -0
  62. package/dist/TxDeferred.js.map +1 -0
  63. package/dist/TxHashMap.d.ts +84 -83
  64. package/dist/TxHashMap.d.ts.map +1 -1
  65. package/dist/TxHashMap.js +24 -24
  66. package/dist/TxHashMap.js.map +1 -1
  67. package/dist/TxHashSet.d.ts +35 -35
  68. package/dist/TxHashSet.d.ts.map +1 -1
  69. package/dist/TxHashSet.js +14 -14
  70. package/dist/TxHashSet.js.map +1 -1
  71. package/dist/TxPriorityQueue.d.ts +609 -0
  72. package/dist/TxPriorityQueue.d.ts.map +1 -0
  73. package/dist/TxPriorityQueue.js +415 -0
  74. package/dist/TxPriorityQueue.js.map +1 -0
  75. package/dist/TxPubSub.d.ts +585 -0
  76. package/dist/TxPubSub.d.ts.map +1 -0
  77. package/dist/TxPubSub.js +521 -0
  78. package/dist/TxPubSub.js.map +1 -0
  79. package/dist/TxQueue.d.ts +32 -32
  80. package/dist/TxQueue.d.ts.map +1 -1
  81. package/dist/TxQueue.js +26 -26
  82. package/dist/TxQueue.js.map +1 -1
  83. package/dist/TxReentrantLock.d.ts +523 -0
  84. package/dist/TxReentrantLock.d.ts.map +1 -0
  85. package/dist/TxReentrantLock.js +504 -0
  86. package/dist/TxReentrantLock.js.map +1 -0
  87. package/dist/TxRef.d.ts +34 -34
  88. package/dist/TxRef.d.ts.map +1 -1
  89. package/dist/TxRef.js +21 -14
  90. package/dist/TxRef.js.map +1 -1
  91. package/dist/TxSemaphore.d.ts +8 -8
  92. package/dist/TxSemaphore.d.ts.map +1 -1
  93. package/dist/TxSemaphore.js +7 -7
  94. package/dist/TxSemaphore.js.map +1 -1
  95. package/dist/TxSubscriptionRef.d.ts +508 -0
  96. package/dist/TxSubscriptionRef.d.ts.map +1 -0
  97. package/dist/TxSubscriptionRef.js +293 -0
  98. package/dist/TxSubscriptionRef.js.map +1 -0
  99. package/dist/index.d.ts +40 -0
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +40 -0
  102. package/dist/index.js.map +1 -1
  103. package/dist/internal/effect.js +99 -42
  104. package/dist/internal/effect.js.map +1 -1
  105. package/dist/internal/hashMap.js +3 -2
  106. package/dist/internal/hashMap.js.map +1 -1
  107. package/dist/internal/trie.js +5 -4
  108. package/dist/internal/trie.js.map +1 -1
  109. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  110. package/dist/unstable/ai/Tool.js +0 -9
  111. package/dist/unstable/ai/Tool.js.map +1 -1
  112. package/dist/unstable/cli/Command.d.ts +1 -1
  113. package/dist/unstable/cli/Command.d.ts.map +1 -1
  114. package/dist/unstable/cli/Command.js +1 -1
  115. package/dist/unstable/cli/Command.js.map +1 -1
  116. package/dist/unstable/cluster/K8sHttpClient.js +4 -4
  117. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  118. package/dist/unstable/cluster/Sharding.js +1 -1
  119. package/dist/unstable/cluster/Sharding.js.map +1 -1
  120. package/dist/unstable/encoding/Sse.js +1 -1
  121. package/dist/unstable/encoding/Sse.js.map +1 -1
  122. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  123. package/dist/unstable/rpc/RpcServer.js +1 -2
  124. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  125. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  126. package/dist/unstable/socket/Socket.js +3 -3
  127. package/dist/unstable/socket/Socket.js.map +1 -1
  128. package/package.json +1 -1
  129. package/src/Array.ts +190 -342
  130. package/src/Cache.ts +6 -5
  131. package/src/Channel.ts +506 -102
  132. package/src/Chunk.ts +81 -268
  133. package/src/Effect.ts +437 -518
  134. package/src/Filter.ts +0 -57
  135. package/src/HashMap.ts +15 -14
  136. package/src/Iterable.ts +105 -50
  137. package/src/Option.ts +30 -20
  138. package/src/Pull.ts +1 -1
  139. package/src/Record.ts +43 -152
  140. package/src/Sink.ts +75 -23
  141. package/src/Stream.ts +442 -502
  142. package/src/Trie.ts +18 -17
  143. package/src/TxChunk.ts +72 -53
  144. package/src/TxDeferred.ts +394 -0
  145. package/src/TxHashMap.ts +332 -285
  146. package/src/TxHashSet.ts +111 -116
  147. package/src/TxPriorityQueue.ts +767 -0
  148. package/src/TxPubSub.ts +789 -0
  149. package/src/TxQueue.ts +241 -251
  150. package/src/TxReentrantLock.ts +753 -0
  151. package/src/TxRef.ts +50 -38
  152. package/src/TxSemaphore.ts +29 -32
  153. package/src/TxSubscriptionRef.ts +639 -0
  154. package/src/index.ts +45 -0
  155. package/src/internal/effect.ts +368 -163
  156. package/src/internal/hashMap.ts +7 -5
  157. package/src/internal/trie.ts +16 -9
  158. package/src/unstable/ai/Tool.ts +0 -9
  159. package/src/unstable/cli/Command.ts +6 -4
  160. package/src/unstable/cluster/K8sHttpClient.ts +4 -4
  161. package/src/unstable/cluster/Sharding.ts +1 -1
  162. package/src/unstable/encoding/Sse.ts +1 -1
  163. package/src/unstable/rpc/RpcServer.ts +1 -7
  164. package/src/unstable/socket/Socket.ts +9 -11
@@ -0,0 +1,508 @@
1
+ /**
2
+ * TxSubscriptionRef is a TxRef that allows subscribing to all committed changes. Subscribers
3
+ * receive the current value followed by every subsequent update via a transactional queue.
4
+ *
5
+ * @since 4.0.0
6
+ */
7
+ import * as Effect from "./Effect.ts";
8
+ import type { Inspectable } from "./Inspectable.ts";
9
+ import type { Pipeable } from "./Pipeable.ts";
10
+ import type * as Scope from "./Scope.ts";
11
+ import * as Stream from "./Stream.ts";
12
+ import * as TxQueue from "./TxQueue.ts";
13
+ declare const TypeId = "~effect/transactions/TxSubscriptionRef";
14
+ /**
15
+ * A TxSubscriptionRef is a transactional reference that allows subscribing to all
16
+ * committed changes. Subscribers receive the current value followed by every subsequent
17
+ * update via a transactional dequeue.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { Effect, TxSubscriptionRef, TxQueue } from "effect"
22
+ *
23
+ * const program = Effect.gen(function*() {
24
+ * const ref = yield* TxSubscriptionRef.make(0)
25
+ *
26
+ * yield* Effect.scoped(
27
+ * Effect.gen(function*() {
28
+ * const sub = yield* TxSubscriptionRef.changes(ref)
29
+ * const initial = yield* TxQueue.take(sub)
30
+ * console.log(initial) // 0
31
+ *
32
+ * yield* TxSubscriptionRef.set(ref, 1)
33
+ * const next = yield* TxQueue.take(sub)
34
+ * console.log(next) // 1
35
+ * })
36
+ * )
37
+ * })
38
+ * ```
39
+ *
40
+ * @since 4.0.0
41
+ * @category models
42
+ */
43
+ export interface TxSubscriptionRef<in out A> extends Inspectable, Pipeable {
44
+ readonly [TypeId]: typeof TypeId;
45
+ }
46
+ /**
47
+ * Creates a new TxSubscriptionRef with the specified initial value.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * import { Effect, TxSubscriptionRef } from "effect"
52
+ *
53
+ * const program = Effect.gen(function*() {
54
+ * const ref = yield* TxSubscriptionRef.make(42)
55
+ * const value = yield* TxSubscriptionRef.get(ref)
56
+ * console.log(value) // 42
57
+ * })
58
+ * ```
59
+ *
60
+ * @since 4.0.0
61
+ * @category constructors
62
+ */
63
+ export declare const make: <A>(value: A) => Effect.Effect<TxSubscriptionRef<A>, never, Effect.Transaction>;
64
+ /**
65
+ * Reads the current value of the TxSubscriptionRef.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * import { Effect, TxSubscriptionRef } from "effect"
70
+ *
71
+ * const program = Effect.gen(function*() {
72
+ * const ref = yield* TxSubscriptionRef.make("hello")
73
+ * const value = yield* TxSubscriptionRef.get(ref)
74
+ * console.log(value) // "hello"
75
+ * })
76
+ * ```
77
+ *
78
+ * @since 4.0.0
79
+ * @category getters
80
+ */
81
+ export declare const get: <A>(self: TxSubscriptionRef<A>) => Effect.Effect<A, never, Effect.Transaction>;
82
+ /**
83
+ * Modifies the value of the TxSubscriptionRef using a function that returns both a
84
+ * result and the new value. The new value is published to all subscribers atomically.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * import { Effect, TxSubscriptionRef } from "effect"
89
+ *
90
+ * const program = Effect.gen(function*() {
91
+ * const ref = yield* TxSubscriptionRef.make(10)
92
+ * const result = yield* TxSubscriptionRef.modify(ref, (n) => [`was ${n}`, n + 1])
93
+ * console.log(result) // "was 10"
94
+ * console.log(yield* TxSubscriptionRef.get(ref)) // 11
95
+ * })
96
+ * ```
97
+ *
98
+ * @since 4.0.0
99
+ * @category mutations
100
+ */
101
+ export declare const modify: {
102
+ /**
103
+ * Modifies the value of the TxSubscriptionRef using a function that returns both a
104
+ * result and the new value. The new value is published to all subscribers atomically.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * import { Effect, TxSubscriptionRef } from "effect"
109
+ *
110
+ * const program = Effect.gen(function*() {
111
+ * const ref = yield* TxSubscriptionRef.make(10)
112
+ * const result = yield* TxSubscriptionRef.modify(ref, (n) => [`was ${n}`, n + 1])
113
+ * console.log(result) // "was 10"
114
+ * console.log(yield* TxSubscriptionRef.get(ref)) // 11
115
+ * })
116
+ * ```
117
+ *
118
+ * @since 4.0.0
119
+ * @category mutations
120
+ */
121
+ <A, B>(f: (current: A) => [returnValue: B, newValue: A]): (self: TxSubscriptionRef<A>) => Effect.Effect<B, never, Effect.Transaction>;
122
+ /**
123
+ * Modifies the value of the TxSubscriptionRef using a function that returns both a
124
+ * result and the new value. The new value is published to all subscribers atomically.
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * import { Effect, TxSubscriptionRef } from "effect"
129
+ *
130
+ * const program = Effect.gen(function*() {
131
+ * const ref = yield* TxSubscriptionRef.make(10)
132
+ * const result = yield* TxSubscriptionRef.modify(ref, (n) => [`was ${n}`, n + 1])
133
+ * console.log(result) // "was 10"
134
+ * console.log(yield* TxSubscriptionRef.get(ref)) // 11
135
+ * })
136
+ * ```
137
+ *
138
+ * @since 4.0.0
139
+ * @category mutations
140
+ */
141
+ <A, B>(self: TxSubscriptionRef<A>, f: (current: A) => [returnValue: B, newValue: A]): Effect.Effect<B, never, Effect.Transaction>;
142
+ };
143
+ /**
144
+ * Sets the value of the TxSubscriptionRef and publishes the new value to all subscribers.
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * import { Effect, TxSubscriptionRef } from "effect"
149
+ *
150
+ * const program = Effect.gen(function*() {
151
+ * const ref = yield* TxSubscriptionRef.make(0)
152
+ * yield* TxSubscriptionRef.set(ref, 42)
153
+ * console.log(yield* TxSubscriptionRef.get(ref)) // 42
154
+ * })
155
+ * ```
156
+ *
157
+ * @since 4.0.0
158
+ * @category mutations
159
+ */
160
+ export declare const set: {
161
+ /**
162
+ * Sets the value of the TxSubscriptionRef and publishes the new value to all subscribers.
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * import { Effect, TxSubscriptionRef } from "effect"
167
+ *
168
+ * const program = Effect.gen(function*() {
169
+ * const ref = yield* TxSubscriptionRef.make(0)
170
+ * yield* TxSubscriptionRef.set(ref, 42)
171
+ * console.log(yield* TxSubscriptionRef.get(ref)) // 42
172
+ * })
173
+ * ```
174
+ *
175
+ * @since 4.0.0
176
+ * @category mutations
177
+ */
178
+ <A>(value: A): (self: TxSubscriptionRef<A>) => Effect.Effect<void, never, Effect.Transaction>;
179
+ /**
180
+ * Sets the value of the TxSubscriptionRef and publishes the new value to all subscribers.
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * import { Effect, TxSubscriptionRef } from "effect"
185
+ *
186
+ * const program = Effect.gen(function*() {
187
+ * const ref = yield* TxSubscriptionRef.make(0)
188
+ * yield* TxSubscriptionRef.set(ref, 42)
189
+ * console.log(yield* TxSubscriptionRef.get(ref)) // 42
190
+ * })
191
+ * ```
192
+ *
193
+ * @since 4.0.0
194
+ * @category mutations
195
+ */
196
+ <A>(self: TxSubscriptionRef<A>, value: A): Effect.Effect<void, never, Effect.Transaction>;
197
+ };
198
+ /**
199
+ * Updates the value of the TxSubscriptionRef using a function and publishes the new
200
+ * value to all subscribers.
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * import { Effect, TxSubscriptionRef } from "effect"
205
+ *
206
+ * const program = Effect.gen(function*() {
207
+ * const ref = yield* TxSubscriptionRef.make(5)
208
+ * yield* TxSubscriptionRef.update(ref, (n) => n * 2)
209
+ * console.log(yield* TxSubscriptionRef.get(ref)) // 10
210
+ * })
211
+ * ```
212
+ *
213
+ * @since 4.0.0
214
+ * @category mutations
215
+ */
216
+ export declare const update: {
217
+ /**
218
+ * Updates the value of the TxSubscriptionRef using a function and publishes the new
219
+ * value to all subscribers.
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * import { Effect, TxSubscriptionRef } from "effect"
224
+ *
225
+ * const program = Effect.gen(function*() {
226
+ * const ref = yield* TxSubscriptionRef.make(5)
227
+ * yield* TxSubscriptionRef.update(ref, (n) => n * 2)
228
+ * console.log(yield* TxSubscriptionRef.get(ref)) // 10
229
+ * })
230
+ * ```
231
+ *
232
+ * @since 4.0.0
233
+ * @category mutations
234
+ */
235
+ <A>(f: (current: A) => A): (self: TxSubscriptionRef<A>) => Effect.Effect<void, never, Effect.Transaction>;
236
+ /**
237
+ * Updates the value of the TxSubscriptionRef using a function and publishes the new
238
+ * value to all subscribers.
239
+ *
240
+ * @example
241
+ * ```ts
242
+ * import { Effect, TxSubscriptionRef } from "effect"
243
+ *
244
+ * const program = Effect.gen(function*() {
245
+ * const ref = yield* TxSubscriptionRef.make(5)
246
+ * yield* TxSubscriptionRef.update(ref, (n) => n * 2)
247
+ * console.log(yield* TxSubscriptionRef.get(ref)) // 10
248
+ * })
249
+ * ```
250
+ *
251
+ * @since 4.0.0
252
+ * @category mutations
253
+ */
254
+ <A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<void, never, Effect.Transaction>;
255
+ };
256
+ /**
257
+ * Gets the current value and sets a new value atomically. Publishes the new value
258
+ * to all subscribers.
259
+ *
260
+ * @example
261
+ * ```ts
262
+ * import { Effect, TxSubscriptionRef } from "effect"
263
+ *
264
+ * const program = Effect.gen(function*() {
265
+ * const ref = yield* TxSubscriptionRef.make("a")
266
+ * const old = yield* TxSubscriptionRef.getAndSet(ref, "b")
267
+ * console.log(old) // "a"
268
+ * console.log(yield* TxSubscriptionRef.get(ref)) // "b"
269
+ * })
270
+ * ```
271
+ *
272
+ * @since 4.0.0
273
+ * @category mutations
274
+ */
275
+ export declare const getAndSet: {
276
+ /**
277
+ * Gets the current value and sets a new value atomically. Publishes the new value
278
+ * to all subscribers.
279
+ *
280
+ * @example
281
+ * ```ts
282
+ * import { Effect, TxSubscriptionRef } from "effect"
283
+ *
284
+ * const program = Effect.gen(function*() {
285
+ * const ref = yield* TxSubscriptionRef.make("a")
286
+ * const old = yield* TxSubscriptionRef.getAndSet(ref, "b")
287
+ * console.log(old) // "a"
288
+ * console.log(yield* TxSubscriptionRef.get(ref)) // "b"
289
+ * })
290
+ * ```
291
+ *
292
+ * @since 4.0.0
293
+ * @category mutations
294
+ */
295
+ <A>(value: A): (self: TxSubscriptionRef<A>) => Effect.Effect<A, never, Effect.Transaction>;
296
+ /**
297
+ * Gets the current value and sets a new value atomically. Publishes the new value
298
+ * to all subscribers.
299
+ *
300
+ * @example
301
+ * ```ts
302
+ * import { Effect, TxSubscriptionRef } from "effect"
303
+ *
304
+ * const program = Effect.gen(function*() {
305
+ * const ref = yield* TxSubscriptionRef.make("a")
306
+ * const old = yield* TxSubscriptionRef.getAndSet(ref, "b")
307
+ * console.log(old) // "a"
308
+ * console.log(yield* TxSubscriptionRef.get(ref)) // "b"
309
+ * })
310
+ * ```
311
+ *
312
+ * @since 4.0.0
313
+ * @category mutations
314
+ */
315
+ <A>(self: TxSubscriptionRef<A>, value: A): Effect.Effect<A, never, Effect.Transaction>;
316
+ };
317
+ /**
318
+ * Gets the current value and updates it using a function atomically. Publishes
319
+ * the new value to all subscribers.
320
+ *
321
+ * @example
322
+ * ```ts
323
+ * import { Effect, TxSubscriptionRef } from "effect"
324
+ *
325
+ * const program = Effect.gen(function*() {
326
+ * const ref = yield* TxSubscriptionRef.make(1)
327
+ * const old = yield* TxSubscriptionRef.getAndUpdate(ref, (n) => n + 10)
328
+ * console.log(old) // 1
329
+ * console.log(yield* TxSubscriptionRef.get(ref)) // 11
330
+ * })
331
+ * ```
332
+ *
333
+ * @since 4.0.0
334
+ * @category mutations
335
+ */
336
+ export declare const getAndUpdate: {
337
+ /**
338
+ * Gets the current value and updates it using a function atomically. Publishes
339
+ * the new value to all subscribers.
340
+ *
341
+ * @example
342
+ * ```ts
343
+ * import { Effect, TxSubscriptionRef } from "effect"
344
+ *
345
+ * const program = Effect.gen(function*() {
346
+ * const ref = yield* TxSubscriptionRef.make(1)
347
+ * const old = yield* TxSubscriptionRef.getAndUpdate(ref, (n) => n + 10)
348
+ * console.log(old) // 1
349
+ * console.log(yield* TxSubscriptionRef.get(ref)) // 11
350
+ * })
351
+ * ```
352
+ *
353
+ * @since 4.0.0
354
+ * @category mutations
355
+ */
356
+ <A>(f: (current: A) => A): (self: TxSubscriptionRef<A>) => Effect.Effect<A, never, Effect.Transaction>;
357
+ /**
358
+ * Gets the current value and updates it using a function atomically. Publishes
359
+ * the new value to all subscribers.
360
+ *
361
+ * @example
362
+ * ```ts
363
+ * import { Effect, TxSubscriptionRef } from "effect"
364
+ *
365
+ * const program = Effect.gen(function*() {
366
+ * const ref = yield* TxSubscriptionRef.make(1)
367
+ * const old = yield* TxSubscriptionRef.getAndUpdate(ref, (n) => n + 10)
368
+ * console.log(old) // 1
369
+ * console.log(yield* TxSubscriptionRef.get(ref)) // 11
370
+ * })
371
+ * ```
372
+ *
373
+ * @since 4.0.0
374
+ * @category mutations
375
+ */
376
+ <A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<A, never, Effect.Transaction>;
377
+ };
378
+ /**
379
+ * Updates the value using a function and returns the new value. Publishes the
380
+ * new value to all subscribers.
381
+ *
382
+ * @example
383
+ * ```ts
384
+ * import { Effect, TxSubscriptionRef } from "effect"
385
+ *
386
+ * const program = Effect.gen(function*() {
387
+ * const ref = yield* TxSubscriptionRef.make(3)
388
+ * const result = yield* TxSubscriptionRef.updateAndGet(ref, (n) => n * 3)
389
+ * console.log(result) // 9
390
+ * })
391
+ * ```
392
+ *
393
+ * @since 4.0.0
394
+ * @category mutations
395
+ */
396
+ export declare const updateAndGet: {
397
+ /**
398
+ * Updates the value using a function and returns the new value. Publishes the
399
+ * new value to all subscribers.
400
+ *
401
+ * @example
402
+ * ```ts
403
+ * import { Effect, TxSubscriptionRef } from "effect"
404
+ *
405
+ * const program = Effect.gen(function*() {
406
+ * const ref = yield* TxSubscriptionRef.make(3)
407
+ * const result = yield* TxSubscriptionRef.updateAndGet(ref, (n) => n * 3)
408
+ * console.log(result) // 9
409
+ * })
410
+ * ```
411
+ *
412
+ * @since 4.0.0
413
+ * @category mutations
414
+ */
415
+ <A>(f: (current: A) => A): (self: TxSubscriptionRef<A>) => Effect.Effect<A, never, Effect.Transaction>;
416
+ /**
417
+ * Updates the value using a function and returns the new value. Publishes the
418
+ * new value to all subscribers.
419
+ *
420
+ * @example
421
+ * ```ts
422
+ * import { Effect, TxSubscriptionRef } from "effect"
423
+ *
424
+ * const program = Effect.gen(function*() {
425
+ * const ref = yield* TxSubscriptionRef.make(3)
426
+ * const result = yield* TxSubscriptionRef.updateAndGet(ref, (n) => n * 3)
427
+ * console.log(result) // 9
428
+ * })
429
+ * ```
430
+ *
431
+ * @since 4.0.0
432
+ * @category mutations
433
+ */
434
+ <A>(self: TxSubscriptionRef<A>, f: (current: A) => A): Effect.Effect<A, never, Effect.Transaction>;
435
+ };
436
+ /**
437
+ * Subscribes to all changes of the TxSubscriptionRef. Returns a scoped TxDequeue
438
+ * that first yields the current value, then every subsequent update.
439
+ *
440
+ * @example
441
+ * ```ts
442
+ * import { Effect, TxSubscriptionRef, TxQueue } from "effect"
443
+ *
444
+ * const program = Effect.gen(function*() {
445
+ * const ref = yield* TxSubscriptionRef.make(0)
446
+ *
447
+ * yield* Effect.scoped(
448
+ * Effect.gen(function*() {
449
+ * const sub = yield* TxSubscriptionRef.changes(ref)
450
+ * const initial = yield* TxQueue.take(sub)
451
+ * console.log(initial) // 0
452
+ *
453
+ * yield* TxSubscriptionRef.set(ref, 1)
454
+ * const next = yield* TxQueue.take(sub)
455
+ * console.log(next) // 1
456
+ * })
457
+ * )
458
+ * })
459
+ * ```
460
+ *
461
+ * @since 4.0.0
462
+ * @category subscriptions
463
+ */
464
+ export declare const changes: <A>(self: TxSubscriptionRef<A>) => Effect.Effect<TxQueue.TxQueue<A>, never, Scope.Scope>;
465
+ /**
466
+ * Returns a Stream of all changes to the TxSubscriptionRef, starting with the
467
+ * current value followed by every subsequent update.
468
+ *
469
+ * @example
470
+ * ```ts
471
+ * import { Effect, Stream, TxSubscriptionRef } from "effect"
472
+ *
473
+ * const program = Effect.gen(function*() {
474
+ * const ref = yield* TxSubscriptionRef.make(0)
475
+ * yield* TxSubscriptionRef.set(ref, 1)
476
+ * yield* TxSubscriptionRef.set(ref, 2)
477
+ *
478
+ * const values = yield* Stream.runCollect(
479
+ * TxSubscriptionRef.changesStream(ref).pipe(Stream.take(1))
480
+ * )
481
+ * console.log(values) // [2]
482
+ * })
483
+ * ```
484
+ *
485
+ * @since 4.0.0
486
+ * @category subscriptions
487
+ */
488
+ export declare const changesStream: <A>(self: TxSubscriptionRef<A>) => Stream.Stream<A, never, never>;
489
+ /**
490
+ * Checks if the given value is a TxSubscriptionRef.
491
+ *
492
+ * @example
493
+ * ```ts
494
+ * import { TxSubscriptionRef } from "effect"
495
+ *
496
+ * declare const someValue: unknown
497
+ *
498
+ * if (TxSubscriptionRef.isTxSubscriptionRef(someValue)) {
499
+ * console.log("This is a TxSubscriptionRef")
500
+ * }
501
+ * ```
502
+ *
503
+ * @since 4.0.0
504
+ * @category guards
505
+ */
506
+ export declare const isTxSubscriptionRef: (u: unknown) => u is TxSubscriptionRef<unknown>;
507
+ export {};
508
+ //# sourceMappingURL=TxSubscriptionRef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TxSubscriptionRef.d.ts","sourceRoot":"","sources":["../src/TxSubscriptionRef.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG7C,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAGvC,QAAA,MAAM,MAAM,2CAA2C,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,iBAAiB,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAE,SAAQ,WAAW,EAAE,QAAQ;IACxE,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,MAAM,CAAA;CAKjC;AAqBD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,WAAW,CAS5F,CAAA;AAMJ;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,EAAE,MAAM,iBAAiB,CAAC,CAAC,C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