@fncts/observable 0.0.32 → 0.0.33

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 (192) hide show
  1. package/LICENSE +26 -0
  2. package/_cjs/Action.cjs +15 -16
  3. package/_cjs/Action.cjs.map +1 -1
  4. package/_cjs/AnimationFrameAction.cjs +30 -35
  5. package/_cjs/AnimationFrameAction.cjs.map +1 -1
  6. package/_cjs/AnimationFrameScheduler.cjs +30 -35
  7. package/_cjs/AnimationFrameScheduler.cjs.map +1 -1
  8. package/_cjs/AsyncAction.cjs +73 -93
  9. package/_cjs/AsyncAction.cjs.map +1 -1
  10. package/_cjs/AsyncScheduler.cjs +35 -41
  11. package/_cjs/AsyncScheduler.cjs.map +1 -1
  12. package/_cjs/BehaviorSubject.cjs +31 -38
  13. package/_cjs/BehaviorSubject.cjs.map +1 -1
  14. package/_cjs/Notification.cjs +65 -66
  15. package/_cjs/Notification.cjs.map +1 -1
  16. package/_cjs/Observable/api/connect.cjs +23 -25
  17. package/_cjs/Observable/api/connect.cjs.map +1 -1
  18. package/_cjs/Observable/api/connectable.cjs +46 -50
  19. package/_cjs/Observable/api/connectable.cjs.map +1 -1
  20. package/_cjs/Observable/api/fromCallback.cjs +44 -48
  21. package/_cjs/Observable/api/fromCallback.cjs.map +1 -1
  22. package/_cjs/Observable/api/fromEvent.cjs +15 -15
  23. package/_cjs/Observable/api/fromEvent.cjs.map +1 -1
  24. package/_cjs/Observable/api/index.cjs +32 -160
  25. package/_cjs/Observable/api/race.cjs +26 -30
  26. package/_cjs/Observable/api/race.cjs.map +1 -1
  27. package/_cjs/Observable/api/raceWith.cjs +14 -15
  28. package/_cjs/Observable/api/raceWith.cjs.map +1 -1
  29. package/_cjs/Observable/api/repeatWhen.cjs +54 -57
  30. package/_cjs/Observable/api/repeatWhen.cjs.map +1 -1
  31. package/_cjs/Observable/api/retryWhen.cjs +37 -41
  32. package/_cjs/Observable/api/retryWhen.cjs.map +1 -1
  33. package/_cjs/Observable/api/share.cjs +73 -83
  34. package/_cjs/Observable/api/share.cjs.map +1 -1
  35. package/_cjs/Observable/api/window.cjs +46 -43
  36. package/_cjs/Observable/api/window.cjs.map +1 -1
  37. package/_cjs/Observable/api/windowCount.cjs +45 -51
  38. package/_cjs/Observable/api/windowCount.cjs.map +1 -1
  39. package/_cjs/Observable/api/windowTime.cjs +73 -74
  40. package/_cjs/Observable/api/windowTime.cjs.map +1 -1
  41. package/_cjs/Observable/api/windowToggle.cjs +71 -74
  42. package/_cjs/Observable/api/windowToggle.cjs.map +1 -1
  43. package/_cjs/Observable/api/windowWhen.cjs +59 -55
  44. package/_cjs/Observable/api/windowWhen.cjs.map +1 -1
  45. package/_cjs/Observable/api.cjs +1858 -2034
  46. package/_cjs/Observable/api.cjs.map +1 -1
  47. package/_cjs/Observable/definition.cjs +107 -120
  48. package/_cjs/Observable/definition.cjs.map +1 -1
  49. package/_cjs/Observable/dom/animationFrames.cjs +30 -33
  50. package/_cjs/Observable/dom/animationFrames.cjs.map +1 -1
  51. package/_cjs/Observable/instances.cjs +0 -2
  52. package/_cjs/Observable.cjs +180 -215
  53. package/_cjs/ObservableRef/api.cjs +188 -189
  54. package/_cjs/ObservableRef/api.cjs.map +1 -1
  55. package/_cjs/ObservableRef/atomic.cjs +25 -25
  56. package/_cjs/ObservableRef/atomic.cjs.map +1 -1
  57. package/_cjs/ObservableRef/definition.cjs +32 -33
  58. package/_cjs/ObservableRef/definition.cjs.map +1 -1
  59. package/_cjs/ObservableRef.cjs +17 -39
  60. package/_cjs/Observer.cjs +0 -2
  61. package/_cjs/Operator.cjs +58 -62
  62. package/_cjs/Operator.cjs.map +1 -1
  63. package/_cjs/Scheduler.cjs +38 -37
  64. package/_cjs/Scheduler.cjs.map +1 -1
  65. package/_cjs/Subject.cjs +163 -201
  66. package/_cjs/Subject.cjs.map +1 -1
  67. package/_cjs/Subscriber.cjs +151 -170
  68. package/_cjs/Subscriber.cjs.map +1 -1
  69. package/_cjs/Subscription.cjs +98 -122
  70. package/_cjs/Subscription.cjs.map +1 -1
  71. package/_cjs/chunk.cjs +28 -0
  72. package/_cjs/config.cjs +11 -12
  73. package/_cjs/config.cjs.map +1 -1
  74. package/_cjs/global.cjs +0 -2
  75. package/_cjs/index.cjs +112 -36
  76. package/_cjs/internal/animationFrameProvider.cjs +32 -38
  77. package/_cjs/internal/animationFrameProvider.cjs.map +1 -1
  78. package/_cjs/internal/args.cjs +12 -12
  79. package/_cjs/internal/args.cjs.map +1 -1
  80. package/_cjs/internal/intervalProvider.cjs +15 -22
  81. package/_cjs/internal/intervalProvider.cjs.map +1 -1
  82. package/_cjs/internal/performanceTimestampProvider.cjs +10 -11
  83. package/_cjs/internal/performanceTimestampProvider.cjs.map +1 -1
  84. package/_cjs/internal/timeoutProvider.cjs +15 -22
  85. package/_cjs/internal/timeoutProvider.cjs.map +1 -1
  86. package/_cjs/internal/timestampProvider.cjs +10 -11
  87. package/_cjs/internal/timestampProvider.cjs.map +1 -1
  88. package/_cjs/internal/util.cjs +60 -68
  89. package/_cjs/internal/util.cjs.map +1 -1
  90. package/_mjs/Action.mjs +12 -8
  91. package/_mjs/Action.mjs.map +1 -1
  92. package/_mjs/AnimationFrameAction.mjs +25 -26
  93. package/_mjs/AnimationFrameAction.mjs.map +1 -1
  94. package/_mjs/AnimationFrameScheduler.mjs +25 -27
  95. package/_mjs/AnimationFrameScheduler.mjs.map +1 -1
  96. package/_mjs/AsyncAction.mjs +69 -84
  97. package/_mjs/AsyncAction.mjs.map +1 -1
  98. package/_mjs/AsyncScheduler.mjs +31 -33
  99. package/_mjs/AsyncScheduler.mjs.map +1 -1
  100. package/_mjs/BehaviorSubject.mjs +28 -30
  101. package/_mjs/BehaviorSubject.mjs.map +1 -1
  102. package/_mjs/Notification.mjs +57 -56
  103. package/_mjs/Notification.mjs.map +1 -1
  104. package/_mjs/Observable/api/connect.mjs +17 -17
  105. package/_mjs/Observable/api/connect.mjs.map +1 -1
  106. package/_mjs/Observable/api/connectable.mjs +39 -40
  107. package/_mjs/Observable/api/connectable.mjs.map +1 -1
  108. package/_mjs/Observable/api/fromCallback.mjs +40 -41
  109. package/_mjs/Observable/api/fromCallback.mjs.map +1 -1
  110. package/_mjs/Observable/api/fromEvent.mjs +12 -8
  111. package/_mjs/Observable/api/fromEvent.mjs.map +1 -1
  112. package/_mjs/Observable/api/index.mjs +15 -15
  113. package/_mjs/Observable/api/race.mjs +20 -22
  114. package/_mjs/Observable/api/race.mjs.map +1 -1
  115. package/_mjs/Observable/api/raceWith.mjs +11 -8
  116. package/_mjs/Observable/api/raceWith.mjs.map +1 -1
  117. package/_mjs/Observable/api/repeatWhen.mjs +48 -49
  118. package/_mjs/Observable/api/repeatWhen.mjs.map +1 -1
  119. package/_mjs/Observable/api/retryWhen.mjs +31 -33
  120. package/_mjs/Observable/api/retryWhen.mjs.map +1 -1
  121. package/_mjs/Observable/api/share.mjs +65 -74
  122. package/_mjs/Observable/api/share.mjs.map +1 -1
  123. package/_mjs/Observable/api/window.mjs +38 -34
  124. package/_mjs/Observable/api/window.mjs.map +1 -1
  125. package/_mjs/Observable/api/windowCount.mjs +39 -43
  126. package/_mjs/Observable/api/windowCount.mjs.map +1 -1
  127. package/_mjs/Observable/api/windowTime.mjs +63 -64
  128. package/_mjs/Observable/api/windowTime.mjs.map +1 -1
  129. package/_mjs/Observable/api/windowToggle.mjs +58 -62
  130. package/_mjs/Observable/api/windowToggle.mjs.map +1 -1
  131. package/_mjs/Observable/api/windowWhen.mjs +50 -46
  132. package/_mjs/Observable/api/windowWhen.mjs.map +1 -1
  133. package/_mjs/Observable/api.mjs +1822 -2031
  134. package/_mjs/Observable/api.mjs.map +1 -1
  135. package/_mjs/Observable/definition.mjs +94 -108
  136. package/_mjs/Observable/definition.mjs.map +1 -1
  137. package/_mjs/Observable/dom/animationFrames.mjs +23 -23
  138. package/_mjs/Observable/dom/animationFrames.mjs.map +1 -1
  139. package/_mjs/Observable/instances.mjs +0 -2
  140. package/_mjs/Observable.mjs +20 -25
  141. package/_mjs/ObservableRef/api.mjs +180 -177
  142. package/_mjs/ObservableRef/api.mjs.map +1 -1
  143. package/_mjs/ObservableRef/atomic.mjs +21 -17
  144. package/_mjs/ObservableRef/atomic.mjs.map +1 -1
  145. package/_mjs/ObservableRef/definition.mjs +29 -25
  146. package/_mjs/ObservableRef/definition.mjs.map +1 -1
  147. package/_mjs/ObservableRef.mjs +4 -5
  148. package/_mjs/Observer.mjs +0 -2
  149. package/_mjs/Operator.mjs +50 -51
  150. package/_mjs/Operator.mjs.map +1 -1
  151. package/_mjs/Scheduler.mjs +30 -26
  152. package/_mjs/Scheduler.mjs.map +1 -1
  153. package/_mjs/Subject.mjs +154 -190
  154. package/_mjs/Subject.mjs.map +1 -1
  155. package/_mjs/Subscriber.mjs +136 -156
  156. package/_mjs/Subscriber.mjs.map +1 -1
  157. package/_mjs/Subscription.mjs +90 -112
  158. package/_mjs/Subscription.mjs.map +1 -1
  159. package/_mjs/config.mjs +10 -6
  160. package/_mjs/config.mjs.map +1 -1
  161. package/_mjs/global.mjs +0 -2
  162. package/_mjs/index.mjs +14 -15
  163. package/_mjs/internal/animationFrameProvider.mjs +28 -30
  164. package/_mjs/internal/animationFrameProvider.mjs.map +1 -1
  165. package/_mjs/internal/args.mjs +9 -5
  166. package/_mjs/internal/args.mjs.map +1 -1
  167. package/_mjs/internal/intervalProvider.mjs +14 -16
  168. package/_mjs/internal/intervalProvider.mjs.map +1 -1
  169. package/_mjs/internal/performanceTimestampProvider.mjs +9 -5
  170. package/_mjs/internal/performanceTimestampProvider.mjs.map +1 -1
  171. package/_mjs/internal/timeoutProvider.mjs +14 -16
  172. package/_mjs/internal/timeoutProvider.mjs.map +1 -1
  173. package/_mjs/internal/timestampProvider.mjs +9 -5
  174. package/_mjs/internal/timestampProvider.mjs.map +1 -1
  175. package/_mjs/internal/util.mjs +54 -59
  176. package/_mjs/internal/util.mjs.map +1 -1
  177. package/_src/Observable/api.ts +1 -1
  178. package/package.json +6 -2
  179. package/_cjs/Observable/api/index.cjs.map +0 -1
  180. package/_cjs/Observable/instances.cjs.map +0 -1
  181. package/_cjs/Observable.cjs.map +0 -1
  182. package/_cjs/ObservableRef.cjs.map +0 -1
  183. package/_cjs/Observer.cjs.map +0 -1
  184. package/_cjs/global.cjs.map +0 -1
  185. package/_cjs/index.cjs.map +0 -1
  186. package/_mjs/Observable/api/index.mjs.map +0 -1
  187. package/_mjs/Observable/instances.mjs.map +0 -1
  188. package/_mjs/Observable.mjs.map +0 -1
  189. package/_mjs/ObservableRef.mjs.map +0 -1
  190. package/_mjs/Observer.mjs.map +0 -1
  191. package/_mjs/global.mjs.map +0 -1
  192. package/_mjs/index.mjs.map +0 -1
package/_mjs/Operator.mjs CHANGED
@@ -1,58 +1,57 @@
1
1
  import * as tsplus_module_1 from "@fncts/observable/Subscriber";
2
2
  import * as tsplus_module_2 from "@fncts/base/data/Cause/api";
3
3
  import * as tsplus_module_3 from "@fncts/base/data/Either/api";
4
- export class OperatorSubscriber extends tsplus_module_1.Subscriber {
5
- onFinalize;
6
- constructor(destination, observer, onFinalize) {
7
- super(destination);
8
- this.onFinalize = onFinalize;
9
- this.next = observer.next ? function (value) {
10
- try {
11
- observer.next(value);
12
- } catch (err) {
13
- destination.error(tsplus_module_2.halt(err));
14
- }
15
- } : super.next;
16
- this.error = observer.error ? function (error) {
17
- try {
18
- observer.error(error);
19
- } catch (err) {
20
- destination.error(tsplus_module_2.halt(err));
21
- this.unsubscribe();
22
- } finally {
23
- if (tsplus_module_3.isRight(tsplus_module_2.failureOrCause(error))) {
24
- this.unsubscribe();
25
- }
26
- }
27
- } : super.error;
28
- this.complete = observer.complete ? function () {
29
- try {
30
- observer.complete();
31
- } catch (err) {
32
- destination.error(tsplus_module_2.halt(err));
33
- } finally {
34
- this.unsubscribe();
35
- }
36
- } : super.complete;
37
- }
38
- unsubscribe() {
39
- const {
40
- _closed: closed
41
- } = this;
42
- super.unsubscribe();
43
- !closed && this.onFinalize?.();
44
- }
45
- }
46
- export function operatorSubscriber(destination, observer, onFinalize) {
47
- return new OperatorSubscriber(destination, observer, onFinalize);
4
+ //#region build/esm/Operator.js
5
+ var OperatorSubscriber = class extends tsplus_module_1.Subscriber {
6
+ onFinalize;
7
+ constructor(destination, observer, onFinalize) {
8
+ super(destination);
9
+ this.onFinalize = onFinalize;
10
+ this.next = observer.next ? function(value) {
11
+ try {
12
+ observer.next(value);
13
+ } catch (err) {
14
+ destination.error(tsplus_module_2.halt(err));
15
+ }
16
+ } : super.next;
17
+ this.error = observer.error ? function(error) {
18
+ try {
19
+ observer.error(error);
20
+ } catch (err) {
21
+ destination.error(tsplus_module_2.halt(err));
22
+ this.unsubscribe();
23
+ } finally {
24
+ if (tsplus_module_3.isRight(tsplus_module_2.failureOrCause(error))) this.unsubscribe();
25
+ }
26
+ } : super.error;
27
+ this.complete = observer.complete ? function() {
28
+ try {
29
+ observer.complete();
30
+ } catch (err) {
31
+ destination.error(tsplus_module_2.halt(err));
32
+ } finally {
33
+ this.unsubscribe();
34
+ }
35
+ } : super.complete;
36
+ }
37
+ unsubscribe() {
38
+ const { _closed: closed } = this;
39
+ super.unsubscribe();
40
+ !closed && this.onFinalize?.();
41
+ }
42
+ };
43
+ function operatorSubscriber(destination, observer, onFinalize) {
44
+ return new OperatorSubscriber(destination, observer, onFinalize);
48
45
  }
49
46
  /**
50
- * @tsplus pipeable fncts.observable.Subscriber operate
51
- */
52
- export function operate_(config) {
53
- return destination => {
54
- // @ts-expect-error
55
- return new tsplus_module_1.Subscriber(destination, config);
56
- };
47
+ * @tsplus pipeable fncts.observable.Subscriber operate
48
+ */
49
+ function operate_(config) {
50
+ return (destination) => {
51
+ return new tsplus_module_1.Subscriber(destination, config);
52
+ };
57
53
  }
54
+ //#endregion
55
+ export { OperatorSubscriber, operate_, operatorSubscriber };
56
+
58
57
  //# sourceMappingURL=Operator.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Operator.mjs","names":["OperatorSubscriber","tsplus_module_1","Subscriber","onFinalize","constructor","destination","observer","next","value","err","error","tsplus_module_2","halt","unsubscribe","tsplus_module_3","isRight","failureOrCause","complete","_closed","closed","operatorSubscriber","operate_","config"],"sources":["../_src/Operator.ts"],"sourcesContent":[null],"mappings":";;;AAKA,OAAM,MAAOA,kBAAyB,SAAQC,eAAA,CAAAC,UAAgB;EAIlDC,UAAA;EAHVC,YACEC,WAAiC,EACjCC,QAAiC,EACzBH,UAAuB;IAE/B,KAAK,CAACE,WAAW,CAAC;IAFV,KAAAF,UAAU,GAAVA,UAAU;IAGlB,IAAI,CAACI,IAAI,GAAGD,QAAQ,CAACC,IAAI,GACrB,UAA0CC,KAAQ;MAChD,IAAI;QACFF,QAAQ,CAACC,IAAK,CAACC,KAAK,CAAC;MACvB,CAAC,CAAC,OAAOC,GAAG,EAAE;QACZJ,WAAW,CAACK,KAAK,CAACC,eAAA,CAAAC,IAAA,CAAWH,GAAG,CAAC,CAAC;MACpC;IACF,CAAC,GACD,KAAK,CAACF,IAAI;IACd,IAAI,CAACG,KAAK,GAAGJ,QAAQ,CAACI,KAAK,GACvB,UAA0CA,KAAe;MACvD,IAAI;QACFJ,QAAQ,CAACI,KAAM,CAACA,KAAK,CAAC;MACxB,CAAC,CAAC,OAAOD,GAAG,EAAE;QACZJ,WAAW,CAACK,KAAK,CAACC,eAAA,CAAAC,IAAA,CAAWH,GAAG,CAAC,CAAC;QAClC,IAAI,CAACI,WAAW,EAAE;MACpB,CAAC,SAAS;QACR,IAAIC,eAAA,CAAAC,OAAA,CAAAJ,eAAA,CAAAK,cAAA,CAAAN,KAAK,EAAyB,EAAE;UAClC,IAAI,CAACG,WAAW,EAAE;QACpB;MACF;IACF,CAAC,GACD,KAAK,CAACH,KAAK;IACf,IAAI,CAACO,QAAQ,GAAGX,QAAQ,CAACW,QAAQ,GAC7B;MACE,IAAI;QACFX,QAAQ,CAACW,QAAS,EAAE;MACtB,CAAC,CAAC,OAAOR,GAAG,EAAE;QACZJ,WAAW,CAACK,KAAK,CAACC,eAAA,CAAAC,IAAA,CAAWH,GAAG,CAAC,CAAC;MACpC,CAAC,SAAS;QACR,IAAI,CAACI,WAAW,EAAE;MACpB;IACF,CAAC,GACD,KAAK,CAACI,QAAQ;EACpB;EACAJ,WAAWA,CAAA;IACT,MAAM;MAAEK,OAAO,EAAEC;IAAM,CAAE,GAAG,IAAI;IAChC,KAAK,CAACN,WAAW,EAAE;IACnB,CAACM,MAAM,IAAI,IAAI,CAAChB,UAAU,GAAE,CAAE;EAChC;;AAEF,OAAM,SAAUiB,kBAAkBA,CAChCf,WAA+B,EAC/BC,QAAiC,EACjCH,UAAuB;EAEvB,OAAO,IAAIH,kBAAkB,CAACK,WAAW,EAAEC,QAAQ,EAAEH,UAAU,CAAC;AAClE;AAEA;;;AAGA,OAAM,SAAUkB,QAAQA,CAASC,MAAmC;EAClE,OAAcjB,WAA6B,IAAwB;IACjE;IACA,OAAO,IAAAJ,eAAA,CAAIC,UAAU,CAASG,WAAW,EAAEiB,MAAM,CAAC;EACpD,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"Operator.mjs","names":[],"sources":["../esm/Operator.js"],"sourcesContent":["import * as tsplus_module_1 from \"@fncts/observable/Subscriber\";\nimport * as tsplus_module_2 from \"@fncts/base/data/Cause/api\";\nimport * as tsplus_module_3 from \"@fncts/base/data/Either/api\";\nexport class OperatorSubscriber extends tsplus_module_1.Subscriber {\n onFinalize;\n constructor(destination, observer, onFinalize) {\n super(destination);\n this.onFinalize = onFinalize;\n this.next = observer.next\n ? function (value) {\n try {\n observer.next(value);\n }\n catch (err) {\n destination.error(tsplus_module_2.halt(err));\n }\n }\n : super.next;\n this.error = observer.error\n ? function (error) {\n try {\n observer.error(error);\n }\n catch (err) {\n destination.error(tsplus_module_2.halt(err));\n this.unsubscribe();\n }\n finally {\n if (tsplus_module_3.isRight(tsplus_module_2.failureOrCause(error))) {\n this.unsubscribe();\n }\n }\n }\n : super.error;\n this.complete = observer.complete\n ? function () {\n try {\n observer.complete();\n }\n catch (err) {\n destination.error(tsplus_module_2.halt(err));\n }\n finally {\n this.unsubscribe();\n }\n }\n : super.complete;\n }\n unsubscribe() {\n const { _closed: closed } = this;\n super.unsubscribe();\n !closed && this.onFinalize?.();\n }\n}\nexport function operatorSubscriber(destination, observer, onFinalize) {\n return new OperatorSubscriber(destination, observer, onFinalize);\n}\n/**\n * @tsplus pipeable fncts.observable.Subscriber operate\n */\nexport function operate_(config) {\n return (destination) => {\n // @ts-expect-error\n return new tsplus_module_1.Subscriber(destination, config);\n };\n}\n//# sourceMappingURL=Operator.js.map"],"mappings":";;;;AAGA,IAAa,qBAAb,cAAwC,gBAAgB,WAAW;CAC/D;CACA,YAAY,aAAa,UAAU,YAAY;AAC3C,QAAM,YAAY;AAClB,OAAK,aAAa;AAClB,OAAK,OAAO,SAAS,OACf,SAAU,OAAO;AACf,OAAI;AACA,aAAS,KAAK,MAAM;YAEjB,KAAK;AACR,gBAAY,MAAM,gBAAgB,KAAK,IAAI,CAAC;;MAGlD,MAAM;AACZ,OAAK,QAAQ,SAAS,QAChB,SAAU,OAAO;AACf,OAAI;AACA,aAAS,MAAM,MAAM;YAElB,KAAK;AACR,gBAAY,MAAM,gBAAgB,KAAK,IAAI,CAAC;AAC5C,SAAK,aAAa;aAEd;AACJ,QAAI,gBAAgB,QAAQ,gBAAgB,eAAe,MAAM,CAAC,CAC9D,MAAK,aAAa;;MAI5B,MAAM;AACZ,OAAK,WAAW,SAAS,WACnB,WAAY;AACV,OAAI;AACA,aAAS,UAAU;YAEhB,KAAK;AACR,gBAAY,MAAM,gBAAgB,KAAK,IAAI,CAAC;aAExC;AACJ,SAAK,aAAa;;MAGxB,MAAM;;CAEhB,cAAc;EACV,MAAM,EAAE,SAAS,WAAW;AAC5B,QAAM,aAAa;AACnB,GAAC,UAAU,KAAK,cAAc;;;AAGtC,SAAgB,mBAAmB,aAAa,UAAU,YAAY;AAClE,QAAO,IAAI,mBAAmB,aAAa,UAAU,WAAW;;;;;AAKpE,SAAgB,SAAS,QAAQ;AAC7B,SAAQ,gBAAgB;AAEpB,SAAO,IAAI,gBAAgB,WAAW,aAAa,OAAO"}
@@ -1,32 +1,36 @@
1
1
  import * as tsplus_module_1 from "@fncts/base/util/predicates";
2
2
  import * as tsplus_module_2 from "@fncts/base/data/Cause/api";
3
3
  import { dateTimestampProvider } from "@fncts/observable/internal/timestampProvider";
4
- export const SchedulerTypeId = /*#__PURE__*/Symbol.for("fncts.observable.Scheduler");
5
- export class Scheduler {
6
- actionConstructor;
7
- [SchedulerTypeId] = SchedulerTypeId;
8
- now;
9
- constructor(actionConstructor, now = Scheduler.now) {
10
- this.actionConstructor = actionConstructor;
11
- this.now = now;
12
- }
13
- schedule(work, delay, state) {
14
- return new this.actionConstructor(this, work).schedule(state, delay);
15
- }
16
- static now = dateTimestampProvider.now;
4
+ //#region build/esm/Scheduler.js
5
+ const SchedulerTypeId = Symbol.for("fncts.observable.Scheduler");
6
+ var Scheduler = class Scheduler {
7
+ actionConstructor;
8
+ [SchedulerTypeId] = SchedulerTypeId;
9
+ now;
10
+ constructor(actionConstructor, now = Scheduler.now) {
11
+ this.actionConstructor = actionConstructor;
12
+ this.now = now;
13
+ }
14
+ schedule(work, delay, state) {
15
+ return new this.actionConstructor(this, work).schedule(state, delay);
16
+ }
17
+ static now = dateTimestampProvider.now;
18
+ };
19
+ function isScheduler(u) {
20
+ return tsplus_module_1.isObject(u) && SchedulerTypeId in u;
17
21
  }
18
- export function isScheduler(u) {
19
- return tsplus_module_1.isObject(u) && SchedulerTypeId in u;
20
- }
21
- export function caughtSchedule(subscriber, scheduler, execute, delay = 0) {
22
- const subscription = scheduler.schedule(function () {
23
- try {
24
- execute.call(this);
25
- } catch (err) {
26
- subscriber.error(tsplus_module_2.halt(err));
27
- }
28
- }, delay);
29
- subscriber.add(subscription);
30
- return subscription;
22
+ function caughtSchedule(subscriber, scheduler, execute, delay = 0) {
23
+ const subscription = scheduler.schedule(function() {
24
+ try {
25
+ execute.call(this);
26
+ } catch (err) {
27
+ subscriber.error(tsplus_module_2.halt(err));
28
+ }
29
+ }, delay);
30
+ subscriber.add(subscription);
31
+ return subscription;
31
32
  }
33
+ //#endregion
34
+ export { Scheduler, SchedulerTypeId, caughtSchedule, isScheduler };
35
+
32
36
  //# sourceMappingURL=Scheduler.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Scheduler.mjs","names":["dateTimestampProvider","SchedulerTypeId","Symbol","for","Scheduler","actionConstructor","now","constructor","schedule","work","delay","state","isScheduler","u","tsplus_module_1","isObject","caughtSchedule","subscriber","scheduler","execute","subscription","call","err","error","tsplus_module_2","halt","add"],"sources":["../_src/Scheduler.ts"],"sourcesContent":[null],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,8CAA8C;AAUpF,OAAO,MAAMC,eAAe,gBAAGC,MAAM,CAACC,GAAG,CAAC,4BAA4B,CAAC;AAGvE,OAAM,MAAOC,SAAS;EAKVC,iBAAA;EAJD,CAACJ,eAAe,IAAqBA,eAAe;EAEtDK,GAAG;EACVC,YACUF,iBAAgC,EACxCC,GAAA,GAAoBF,SAAS,CAACE,GAAG;IADzB,KAAAD,iBAAiB,GAAjBA,iBAAiB;IAGzB,IAAI,CAACC,GAAG,GAAGA,GAAG;EAChB;EACAE,QAAQA,CAAIC,IAAmD,EAAEC,KAAc,EAAEC,KAAS;IACxF,OAAO,IAAI,IAAI,CAACN,iBAAiB,CAAC,IAAI,EAAEI,IAAI,CAAC,CAACD,QAAQ,CAACG,KAAK,EAAED,KAAK,CAAC;EACtE;EACO,OAAOJ,GAAG,GAAiBN,qBAAqB,CAACM,GAAG;;AAG7D,OAAM,SAAUM,WAAWA,CAACC,CAAU;EACpC,OAAOC,eAAA,CAAAC,QAAQ,CAACF,CAAC,CAAC,IAAIZ,eAAe,IAAIY,CAAC;AAC5C;AAEA,OAAM,SAAUG,cAAcA,CAC5BC,UAA4B,EAC5BC,SAAwB,EACxBC,OAA6C,EAC7CT,KAAK,GAAG,CAAC;EAET,MAAMU,YAAY,GAAGF,SAAS,CAACV,QAAQ,CAAC;IACtC,IAAI;MACFW,OAAO,CAACE,IAAI,CAAC,IAAI,CAAC;IACpB,CAAC,CAAC,OAAOC,GAAG,EAAE;MACZL,UAAU,CAACM,KAAK,CAACC,eAAA,CAAAC,IAAA,CAAWH,GAAG,CAAC,CAAC;IACnC;EACF,CAAC,EAAEZ,KAAK,CAAC;EACTO,UAAU,CAACS,GAAG,CAACN,YAAY,CAAC;EAC5B,OAAOA,YAAY;AACrB","ignoreList":[]}
1
+ {"version":3,"file":"Scheduler.mjs","names":[],"sources":["../esm/Scheduler.js"],"sourcesContent":["import * as tsplus_module_1 from \"@fncts/base/util/predicates\";\nimport * as tsplus_module_2 from \"@fncts/base/data/Cause/api\";\nimport { dateTimestampProvider } from \"@fncts/observable/internal/timestampProvider\";\nexport const SchedulerTypeId = Symbol.for(\"fncts.observable.Scheduler\");\nexport class Scheduler {\n actionConstructor;\n [SchedulerTypeId] = SchedulerTypeId;\n now;\n constructor(actionConstructor, now = Scheduler.now) {\n this.actionConstructor = actionConstructor;\n this.now = now;\n }\n schedule(work, delay, state) {\n return new this.actionConstructor(this, work).schedule(state, delay);\n }\n static now = dateTimestampProvider.now;\n}\nexport function isScheduler(u) {\n return tsplus_module_1.isObject(u) && SchedulerTypeId in u;\n}\nexport function caughtSchedule(subscriber, scheduler, execute, delay = 0) {\n const subscription = scheduler.schedule(function () {\n try {\n execute.call(this);\n }\n catch (err) {\n subscriber.error(tsplus_module_2.halt(err));\n }\n }, delay);\n subscriber.add(subscription);\n return subscription;\n}\n//# sourceMappingURL=Scheduler.js.map"],"mappings":";;;;AAGA,MAAa,kBAAkB,OAAO,IAAI,6BAA6B;AACvE,IAAa,YAAb,MAAa,UAAU;CACnB;CACA,CAAC,mBAAmB;CACpB;CACA,YAAY,mBAAmB,MAAM,UAAU,KAAK;AAChD,OAAK,oBAAoB;AACzB,OAAK,MAAM;;CAEf,SAAS,MAAM,OAAO,OAAO;AACzB,SAAO,IAAI,KAAK,kBAAkB,MAAM,KAAK,CAAC,SAAS,OAAO,MAAM;;CAExE,OAAO,MAAM,sBAAsB;;AAEvC,SAAgB,YAAY,GAAG;AAC3B,QAAO,gBAAgB,SAAS,EAAE,IAAI,mBAAmB;;AAE7D,SAAgB,eAAe,YAAY,WAAW,SAAS,QAAQ,GAAG;CACtE,MAAM,eAAe,UAAU,SAAS,WAAY;AAChD,MAAI;AACA,WAAQ,KAAK,KAAK;WAEf,KAAK;AACR,cAAW,MAAM,gBAAgB,KAAK,IAAI,CAAC;;IAEhD,MAAM;AACT,YAAW,IAAI,aAAa;AAC5B,QAAO"}
package/_mjs/Subject.mjs CHANGED
@@ -1,196 +1,160 @@
1
- const fileName_1 = "(@fncts/observable) src/Subject.ts";
2
1
  import * as tsplus_module_1 from "@fncts/observable/Observable";
3
2
  import * as tsplus_module_2 from "@fncts/observable/Subscription";
4
3
  import * as tsplus_module_3 from "@fncts/base/data/Either/destructors";
5
4
  import * as tsplus_module_4 from "@fncts/base/data/Either/constructors";
5
+ //#region build/esm/Subject.js
6
+ const fileName_1 = "(@fncts/observable) src/Subject.ts";
6
7
  /**
7
- * A Subject is a special type of Observable that allows values to be
8
- * multicasted to many Observers. Subjects are like EventEmitters.
9
- *
10
- * Every Subject is an Observable and an Observer. You can subscribe to a
11
- * Subject, and you can call next to feed values as well as error and complete.
12
- */
13
- export class Subject extends tsplus_module_1.Observable {
14
- _closed = false;
15
- currentObservers = /*#__PURE__*/new Map();
16
- observersCount = 0;
17
- observerSnapshot;
18
- hasError = false;
19
- thrownError = null;
20
- constructor() {
21
- super();
22
- }
23
- get closed() {
24
- return this._closed;
25
- }
26
- get observers() {
27
- return this.observerSnapshot ??= Array.from(this.currentObservers.values());
28
- }
29
- next(value) {
30
- if (!this._closed) {
31
- const {
32
- observers
33
- } = this;
34
- const len = observers.length;
35
- for (let i = 0; i < len; i++) {
36
- observers[i].next(value);
37
- }
38
- }
39
- }
40
- error(err) {
41
- if (!this._closed) {
42
- this.hasError = this._closed = true;
43
- this.thrownError = err;
44
- const {
45
- observers
46
- } = this;
47
- const len = observers.length;
48
- for (let i = 0; i < len; i++) {
49
- observers[i].error(err);
50
- }
51
- this.clearObservers();
52
- }
53
- }
54
- complete() {
55
- if (!this._closed) {
56
- this._closed = true;
57
- const {
58
- observers
59
- } = this;
60
- const len = observers.length;
61
- for (let i = 0; i < len; i++) {
62
- observers[i].complete();
63
- }
64
- this.clearObservers();
65
- }
66
- }
67
- unsubscribe() {
68
- this._closed = true;
69
- this.clearObservers();
70
- }
71
- get observed() {
72
- return this.currentObservers.size > 0;
73
- }
74
- throwIfClosed() {
75
- if (this._closed) {
76
- throw new Error("Object Unsubscribed");
77
- }
78
- }
79
- clearObservers() {
80
- this.currentObservers.clear();
81
- this.observerSnapshot = undefined;
82
- }
83
- trySubscribe(subscriber, environment) {
84
- this.throwIfClosed();
85
- return super.trySubscribe(subscriber, environment);
86
- }
87
- subscribeInternal(subscriber) {
88
- this.checkFinalizedStatuses(subscriber);
89
- return this.innerSubscribe(subscriber);
90
- }
91
- innerSubscribe(subscriber) {
92
- const {
93
- hasError,
94
- _closed: closed
95
- } = this;
96
- if (hasError || closed) {
97
- return tsplus_module_2.EMPTY_SUBSCRIPTION;
98
- }
99
- const {
100
- currentObservers
101
- } = this;
102
- const observerId = this.observersCount++;
103
- currentObservers.set(observerId, subscriber);
104
- this.observerSnapshot = undefined;
105
- subscriber.add(() => {
106
- currentObservers.delete(observerId);
107
- this.observerSnapshot = undefined;
108
- });
109
- return subscriber;
110
- }
111
- checkFinalizedStatuses(subscriber) {
112
- const {
113
- hasError,
114
- thrownError,
115
- _closed: closed
116
- } = this;
117
- if (hasError) {
118
- subscriber.error(thrownError);
119
- } else if (closed) {
120
- subscriber.complete();
121
- }
122
- }
123
- asObservable() {
124
- const observable = new tsplus_module_1.Observable();
125
- observable.source = this;
126
- return observable;
127
- }
128
- }
129
- export class AnonymousSubject extends Subject {
130
- destination;
131
- constructor(destination, source) {
132
- super();
133
- this.destination = destination;
134
- this.source = source;
135
- }
136
- next(value) {
137
- this.destination?.next?.(value);
138
- }
139
- error(err) {
140
- this.destination?.error?.(err);
141
- }
142
- complete() {
143
- this.destination?.complete?.();
144
- }
145
- /** @internal */
146
- subscribeInternal(subscriber) {
147
- return this.source?.provideEnvironment(this.environment).subscribe(subscriber) ?? tsplus_module_2.EMPTY_SUBSCRIPTION;
148
- }
149
- }
150
- export class AsyncSubject extends Subject {
151
- value = null;
152
- hasValue = false;
153
- isComplete = false;
154
- /** @internal */
155
- checkFinalizedStatuses(subscriber) {
156
- const {
157
- hasError,
158
- hasValue,
159
- value,
160
- thrownError,
161
- _closed: closed,
162
- isComplete
163
- } = this;
164
- if (hasError) {
165
- subscriber.error(thrownError);
166
- } else if (closed || isComplete) {
167
- hasValue && tsplus_module_3.match(e => subscriber.error(e), a => subscriber.next(a))(value);
168
- subscriber.complete();
169
- }
170
- }
171
- next(value) {
172
- if (!this._closed) {
173
- this.value = tsplus_module_4.right(value, fileName_1 + ":177:35");
174
- this.hasValue = true;
175
- }
176
- }
177
- error(err) {
178
- if (!this._closed) {
179
- this.value = tsplus_module_4.left(err, fileName_1 + ":184:34");
180
- this.hasValue = true;
181
- }
182
- }
183
- complete() {
184
- const {
185
- hasValue,
186
- value,
187
- isComplete
188
- } = this;
189
- if (!isComplete) {
190
- this.isComplete = true;
191
- hasValue && tsplus_module_3.match(e => super.error(e), a => super.next(a))(value);
192
- super.complete();
193
- }
194
- }
195
- }
8
+ * A Subject is a special type of Observable that allows values to be
9
+ * multicasted to many Observers. Subjects are like EventEmitters.
10
+ *
11
+ * Every Subject is an Observable and an Observer. You can subscribe to a
12
+ * Subject, and you can call next to feed values as well as error and complete.
13
+ */
14
+ var Subject = class extends tsplus_module_1.Observable {
15
+ _closed = false;
16
+ currentObservers = /* @__PURE__ */ new Map();
17
+ observersCount = 0;
18
+ observerSnapshot;
19
+ hasError = false;
20
+ thrownError = null;
21
+ constructor() {
22
+ super();
23
+ }
24
+ get closed() {
25
+ return this._closed;
26
+ }
27
+ get observers() {
28
+ return this.observerSnapshot ??= Array.from(this.currentObservers.values());
29
+ }
30
+ next(value) {
31
+ if (!this._closed) {
32
+ const { observers } = this;
33
+ const len = observers.length;
34
+ for (let i = 0; i < len; i++) observers[i].next(value);
35
+ }
36
+ }
37
+ error(err) {
38
+ if (!this._closed) {
39
+ this.hasError = this._closed = true;
40
+ this.thrownError = err;
41
+ const { observers } = this;
42
+ const len = observers.length;
43
+ for (let i = 0; i < len; i++) observers[i].error(err);
44
+ this.clearObservers();
45
+ }
46
+ }
47
+ complete() {
48
+ if (!this._closed) {
49
+ this._closed = true;
50
+ const { observers } = this;
51
+ const len = observers.length;
52
+ for (let i = 0; i < len; i++) observers[i].complete();
53
+ this.clearObservers();
54
+ }
55
+ }
56
+ unsubscribe() {
57
+ this._closed = true;
58
+ this.clearObservers();
59
+ }
60
+ get observed() {
61
+ return this.currentObservers.size > 0;
62
+ }
63
+ throwIfClosed() {
64
+ if (this._closed) throw new Error("Object Unsubscribed");
65
+ }
66
+ clearObservers() {
67
+ this.currentObservers.clear();
68
+ this.observerSnapshot = void 0;
69
+ }
70
+ trySubscribe(subscriber, environment) {
71
+ this.throwIfClosed();
72
+ return super.trySubscribe(subscriber, environment);
73
+ }
74
+ subscribeInternal(subscriber) {
75
+ this.checkFinalizedStatuses(subscriber);
76
+ return this.innerSubscribe(subscriber);
77
+ }
78
+ innerSubscribe(subscriber) {
79
+ const { hasError, _closed: closed } = this;
80
+ if (hasError || closed) return tsplus_module_2.EMPTY_SUBSCRIPTION;
81
+ const { currentObservers } = this;
82
+ const observerId = this.observersCount++;
83
+ currentObservers.set(observerId, subscriber);
84
+ this.observerSnapshot = void 0;
85
+ subscriber.add(() => {
86
+ currentObservers.delete(observerId);
87
+ this.observerSnapshot = void 0;
88
+ });
89
+ return subscriber;
90
+ }
91
+ checkFinalizedStatuses(subscriber) {
92
+ const { hasError, thrownError, _closed: closed } = this;
93
+ if (hasError) subscriber.error(thrownError);
94
+ else if (closed) subscriber.complete();
95
+ }
96
+ asObservable() {
97
+ const observable = new tsplus_module_1.Observable();
98
+ observable.source = this;
99
+ return observable;
100
+ }
101
+ };
102
+ var AnonymousSubject = class extends Subject {
103
+ destination;
104
+ constructor(destination, source) {
105
+ super();
106
+ this.destination = destination;
107
+ this.source = source;
108
+ }
109
+ next(value) {
110
+ this.destination?.next?.(value);
111
+ }
112
+ error(err) {
113
+ this.destination?.error?.(err);
114
+ }
115
+ complete() {
116
+ this.destination?.complete?.();
117
+ }
118
+ /** @internal */
119
+ subscribeInternal(subscriber) {
120
+ return this.source?.provideEnvironment(this.environment).subscribe(subscriber) ?? tsplus_module_2.EMPTY_SUBSCRIPTION;
121
+ }
122
+ };
123
+ var AsyncSubject = class extends Subject {
124
+ value = null;
125
+ hasValue = false;
126
+ isComplete = false;
127
+ /** @internal */
128
+ checkFinalizedStatuses(subscriber) {
129
+ const { hasError, hasValue, value, thrownError, _closed: closed, isComplete } = this;
130
+ if (hasError) subscriber.error(thrownError);
131
+ else if (closed || isComplete) {
132
+ hasValue && tsplus_module_3.match((e) => subscriber.error(e), (a) => subscriber.next(a))(value);
133
+ subscriber.complete();
134
+ }
135
+ }
136
+ next(value) {
137
+ if (!this._closed) {
138
+ this.value = tsplus_module_4.right(value, fileName_1 + ":177:35");
139
+ this.hasValue = true;
140
+ }
141
+ }
142
+ error(err) {
143
+ if (!this._closed) {
144
+ this.value = tsplus_module_4.left(err, fileName_1 + ":184:34");
145
+ this.hasValue = true;
146
+ }
147
+ }
148
+ complete() {
149
+ const { hasValue, value, isComplete } = this;
150
+ if (!isComplete) {
151
+ this.isComplete = true;
152
+ hasValue && tsplus_module_3.match((e) => super.error(e), (a) => super.next(a))(value);
153
+ super.complete();
154
+ }
155
+ }
156
+ };
157
+ //#endregion
158
+ export { AnonymousSubject, AsyncSubject, Subject };
159
+
196
160
  //# sourceMappingURL=Subject.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Subject.mjs","names":["Subject","tsplus_module_1","Observable","_closed","currentObservers","Map","observersCount","observerSnapshot","hasError","thrownError","constructor","closed","observers","Array","from","values","next","value","len","length","i","error","err","clearObservers","complete","unsubscribe","observed","size","throwIfClosed","Error","clear","undefined","trySubscribe","subscriber","environment","subscribeInternal","checkFinalizedStatuses","innerSubscribe","tsplus_module_2","EMPTY_SUBSCRIPTION","observerId","set","add","delete","asObservable","observable","source","AnonymousSubject","destination","provideEnvironment","subscribe","AsyncSubject","hasValue","isComplete","tsplus_module_3","match","e","a","tsplus_module_4","right","fileName_1","left"],"sources":["../_src/Subject.ts"],"sourcesContent":[null],"mappings":";;;;;AAEA;;;;;;;AAOA,OAAM,MAAOA,OAAiB,SAAQC,eAAA,CAAAC,UAAmB;EACvDC,OAAO,GAAG,KAAK;EAELC,gBAAgB,gBAAG,IAAIC,GAAG,EAA0B;EACtDC,cAAc,GAAO,CAAC;EACtBC,gBAAgB;EAEdC,QAAQ,GAAgB,KAAK;EAC7BC,WAAW,GAAa,IAAK;EAEvCC,YAAA;IACE,KAAK,EAAE;EACT;EAEA,IAAIC,MAAMA,CAAA;IACR,OAAO,IAAI,CAACR,OAAO;EACrB;EAEA,IAAIS,SAASA,CAAA;IACX,OAAQ,IAAI,CAACL,gBAAgB,KAAKM,KAAK,CAACC,IAAI,CAAC,IAAI,CAACV,gBAAgB,CAACW,MAAM,EAAE,CAAC;EAC9E;EAEAC,IAAIA,CAACC,KAAQ;IACX,IAAI,CAAC,IAAI,CAACd,OAAO,EAAE;MACjB,MAAM;QAAES;MAAS,CAAE,GAAG,IAAI;MAC1B,MAAMM,GAAG,GAAaN,SAAS,CAACO,MAAM;MACtC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,GAAG,EAAEE,CAAC,EAAE,EAAE;QAC5BR,SAAS,CAACQ,CAAC,CAAC,CAACJ,IAAI,CAACC,KAAK,CAAC;MAC1B;IACF;EACF;EAEAI,KAAKA,CAACC,GAAa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,CAGL;MACHgB,UAAU,CAACT,QAAQ,EAAE;IACvB;EACF;EAEAR,IAAIA,CAACC,KAAQ;IACX,IAAI,CAAC,IAAI,CAACd,OAAO,EAAE;MACjB,IAAI,CAACc,KAAK,GAAMyC,eAAA,CAAAC,KAAA,CAAa1C,KAAK,EAAA2C,UAAA,aAAC;MACnC,IAAI,CAACR,QAAQ,GAAG,IAAI;IACtB;EACF;EAEA/B,KAAKA,CAACC,GAAa;IACjB,IAAI,CAAC,IAAI,CAACnB,OAAO,EAAE;MACjB,IAAI,CAACc,KAAK,GAAMyC,eAAA,CAAAG,IAAA,CAAYvC,GAAG,EAAAsC,UAAA,aAAC;MAChC,IAAI,CAACR,QAAQ,GAAG,IAAI;IACtB;EACF;EAEA5B,QAAQA,CAAA;IACN,MAAM;MAAE4B,QAAQ;MAAEnC,KAAK;MAAEoC;IAAU,CAAE,GAAG,IAAI;IAC5C,IAAI,CAACA,UAAU,EAAE;MACf,IAAI,CAACA,UAAU,GAAG,IAAI;MACtBD,QAAQ,IACNE,eAAA,CAAAC,KAAA,CACGC,CAAC,IAAK,KAAK,CAACnC,KAAK,CAACmC,CAAC,CAAC,EACpBC,CAAC,IAAK,KAAK,CAACzC,IAAI,CAACyC,CAAC,CAAC,EAFtBxC,KAAM,CAGL;MACH,KAAK,CAACO,QAAQ,EAAE;IAClB;EACF","ignoreList":[]}
1
+ {"version":3,"file":"Subject.mjs","names":[],"sources":["../esm/Subject.js"],"sourcesContent":["const fileName_1 = \"(@fncts/observable) src/Subject.ts\";\nimport * as tsplus_module_1 from \"@fncts/observable/Observable\";\nimport * as tsplus_module_2 from \"@fncts/observable/Subscription\";\nimport * as tsplus_module_3 from \"@fncts/base/data/Either/destructors\";\nimport * as tsplus_module_4 from \"@fncts/base/data/Either/constructors\";\n/**\n * A Subject is a special type of Observable that allows values to be\n * multicasted to many Observers. Subjects are like EventEmitters.\n *\n * Every Subject is an Observable and an Observer. You can subscribe to a\n * Subject, and you can call next to feed values as well as error and complete.\n */\nexport class Subject extends tsplus_module_1.Observable {\n _closed = false;\n currentObservers = new Map();\n observersCount = 0;\n observerSnapshot;\n hasError = false;\n thrownError = null;\n constructor() {\n super();\n }\n get closed() {\n return this._closed;\n }\n get observers() {\n return (this.observerSnapshot ??= Array.from(this.currentObservers.values()));\n }\n next(value) {\n if (!this._closed) {\n const { observers } = this;\n const len = observers.length;\n for (let i = 0; i < len; i++) {\n observers[i].next(value);\n }\n }\n }\n error(err) {\n if (!this._closed) {\n this.hasError = this._closed = true;\n this.thrownError = err;\n const { observers } = this;\n const len = observers.length;\n for (let i = 0; i < len; i++) {\n observers[i].error(err);\n }\n this.clearObservers();\n }\n }\n complete() {\n if (!this._closed) {\n this._closed = true;\n const { observers } = this;\n const len = observers.length;\n for (let i = 0; i < len; i++) {\n observers[i].complete();\n }\n this.clearObservers();\n }\n }\n unsubscribe() {\n this._closed = true;\n this.clearObservers();\n }\n get observed() {\n return this.currentObservers.size > 0;\n }\n throwIfClosed() {\n if (this._closed) {\n throw new Error(\"Object Unsubscribed\");\n }\n }\n clearObservers() {\n this.currentObservers.clear();\n this.observerSnapshot = undefined;\n }\n trySubscribe(subscriber, environment) {\n this.throwIfClosed();\n return super.trySubscribe(subscriber, environment);\n }\n subscribeInternal(subscriber) {\n this.checkFinalizedStatuses(subscriber);\n return this.innerSubscribe(subscriber);\n }\n innerSubscribe(subscriber) {\n const { hasError, _closed: closed } = this;\n if (hasError || closed) {\n return tsplus_module_2.EMPTY_SUBSCRIPTION;\n }\n const { currentObservers } = this;\n const observerId = this.observersCount++;\n currentObservers.set(observerId, subscriber);\n this.observerSnapshot = undefined;\n subscriber.add(() => {\n currentObservers.delete(observerId);\n this.observerSnapshot = undefined;\n });\n return subscriber;\n }\n checkFinalizedStatuses(subscriber) {\n const { hasError, thrownError, _closed: closed } = this;\n if (hasError) {\n subscriber.error(thrownError);\n }\n else if (closed) {\n subscriber.complete();\n }\n }\n asObservable() {\n const observable = new tsplus_module_1.Observable();\n observable.source = this;\n return observable;\n }\n}\nexport class AnonymousSubject extends Subject {\n destination;\n constructor(destination, source) {\n super();\n this.destination = destination;\n this.source = source;\n }\n next(value) {\n this.destination?.next?.(value);\n }\n error(err) {\n this.destination?.error?.(err);\n }\n complete() {\n this.destination?.complete?.();\n }\n /** @internal */\n subscribeInternal(subscriber) {\n return this.source?.provideEnvironment(this.environment).subscribe(subscriber) ?? tsplus_module_2.EMPTY_SUBSCRIPTION;\n }\n}\nexport class AsyncSubject extends Subject {\n value = null;\n hasValue = false;\n isComplete = false;\n /** @internal */\n checkFinalizedStatuses(subscriber) {\n const { hasError, hasValue, value, thrownError, _closed: closed, isComplete } = this;\n if (hasError) {\n subscriber.error(thrownError);\n }\n else if (closed || isComplete) {\n hasValue &&\n tsplus_module_3.match((e) => subscriber.error(e), (a) => subscriber.next(a))(value);\n subscriber.complete();\n }\n }\n next(value) {\n if (!this._closed) {\n this.value = tsplus_module_4.right(value, fileName_1 + \":177:35\");\n this.hasValue = true;\n }\n }\n error(err) {\n if (!this._closed) {\n this.value = tsplus_module_4.left(err, fileName_1 + \":184:34\");\n this.hasValue = true;\n }\n }\n complete() {\n const { hasValue, value, isComplete } = this;\n if (!isComplete) {\n this.isComplete = true;\n hasValue &&\n tsplus_module_3.match((e) => super.error(e), (a) => super.next(a))(value);\n super.complete();\n }\n }\n}\n//# sourceMappingURL=Subject.js.map"],"mappings":";;;;;AAAA,MAAM,aAAa;;;;;;;;AAYnB,IAAa,UAAb,cAA6B,gBAAgB,WAAW;CACpD,UAAU;CACV,mCAAmB,IAAI,KAAK;CAC5B,iBAAiB;CACjB;CACA,WAAW;CACX,cAAc;CACd,cAAc;AACV,SAAO;;CAEX,IAAI,SAAS;AACT,SAAO,KAAK;;CAEhB,IAAI,YAAY;AACZ,SAAQ,KAAK,qBAAqB,MAAM,KAAK,KAAK,iBAAiB,QAAQ,CAAC;;CAEhF,KAAK,OAAO;AACR,MAAI,CAAC,KAAK,SAAS;GACf,MAAM,EAAE,cAAc;GAC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