grainjs 1.0.2 → 1.1.0

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 (138) hide show
  1. package/README.md +23 -71
  2. package/dist/cjs/index.js +5 -1
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/lib/PriorityQueue.d.ts +1 -1
  5. package/dist/cjs/lib/_computed_queue.js +3 -3
  6. package/dist/cjs/lib/_computed_queue.js.map +1 -1
  7. package/dist/cjs/lib/binding.d.ts +11 -4
  8. package/dist/cjs/lib/binding.js +5 -5
  9. package/dist/cjs/lib/binding.js.map +1 -1
  10. package/dist/cjs/lib/computed.d.ts +49 -28
  11. package/dist/cjs/lib/computed.js +38 -52
  12. package/dist/cjs/lib/computed.js.map +1 -1
  13. package/dist/cjs/lib/dispose.d.ts +109 -96
  14. package/dist/cjs/lib/dispose.js +106 -80
  15. package/dist/cjs/lib/dispose.js.map +1 -1
  16. package/dist/cjs/lib/dom.d.ts +38 -18
  17. package/dist/cjs/lib/dom.js +44 -20
  18. package/dist/cjs/lib/dom.js.map +1 -1
  19. package/dist/cjs/lib/domComponent.d.ts +56 -48
  20. package/dist/cjs/lib/domComponent.js +66 -1
  21. package/dist/cjs/lib/domComponent.js.map +1 -1
  22. package/dist/cjs/lib/domComputed.d.ts +31 -21
  23. package/dist/cjs/lib/domComputed.js +14 -11
  24. package/dist/cjs/lib/domComputed.js.map +1 -1
  25. package/dist/cjs/lib/domDispose.d.ts +27 -12
  26. package/dist/cjs/lib/domDispose.js +26 -11
  27. package/dist/cjs/lib/domDispose.js.map +1 -1
  28. package/dist/cjs/lib/domForEach.d.ts +4 -3
  29. package/dist/cjs/lib/domForEach.js +10 -9
  30. package/dist/cjs/lib/domForEach.js.map +1 -1
  31. package/dist/cjs/lib/domImpl.d.ts +33 -10
  32. package/dist/cjs/lib/domImpl.js +28 -9
  33. package/dist/cjs/lib/domImpl.js.map +1 -1
  34. package/dist/cjs/lib/domMethods.d.ts +93 -47
  35. package/dist/cjs/lib/domMethods.js +88 -46
  36. package/dist/cjs/lib/domMethods.js.map +1 -1
  37. package/dist/cjs/lib/domevent.d.ts +87 -62
  38. package/dist/cjs/lib/domevent.js +84 -59
  39. package/dist/cjs/lib/domevent.js.map +1 -1
  40. package/dist/cjs/lib/emit.d.ts +62 -32
  41. package/dist/cjs/lib/emit.js +67 -53
  42. package/dist/cjs/lib/emit.js.map +1 -1
  43. package/dist/cjs/lib/kowrap.d.ts +6 -3
  44. package/dist/cjs/lib/kowrap.js +6 -3
  45. package/dist/cjs/lib/kowrap.js.map +1 -1
  46. package/dist/cjs/lib/obsArray.d.ts +91 -53
  47. package/dist/cjs/lib/obsArray.js +87 -55
  48. package/dist/cjs/lib/obsArray.js.map +1 -1
  49. package/dist/cjs/lib/observable.d.ts +25 -15
  50. package/dist/cjs/lib/observable.js +29 -18
  51. package/dist/cjs/lib/observable.js.map +1 -1
  52. package/dist/cjs/lib/pureComputed.d.ts +12 -15
  53. package/dist/cjs/lib/pureComputed.js +15 -18
  54. package/dist/cjs/lib/pureComputed.js.map +1 -1
  55. package/dist/cjs/lib/styled.d.ts +78 -61
  56. package/dist/cjs/lib/styled.js +26 -79
  57. package/dist/cjs/lib/styled.js.map +1 -1
  58. package/dist/cjs/lib/subscribe.d.ts +41 -37
  59. package/dist/cjs/lib/subscribe.js +31 -40
  60. package/dist/cjs/lib/subscribe.js.map +1 -1
  61. package/dist/cjs/lib/util.js +1 -0
  62. package/dist/cjs/lib/util.js.map +1 -1
  63. package/dist/cjs/lib/widgets/input.d.ts +3 -1
  64. package/dist/cjs/lib/widgets/input.js +6 -4
  65. package/dist/cjs/lib/widgets/input.js.map +1 -1
  66. package/dist/cjs/lib/widgets/select.d.ts +4 -2
  67. package/dist/cjs/lib/widgets/select.js +7 -5
  68. package/dist/cjs/lib/widgets/select.js.map +1 -1
  69. package/dist/esm/lib/_computed_queue.js +3 -3
  70. package/dist/esm/lib/_computed_queue.js.map +1 -1
  71. package/dist/esm/lib/binding.js +2 -2
  72. package/dist/esm/lib/binding.js.map +1 -1
  73. package/dist/esm/lib/computed.js +36 -50
  74. package/dist/esm/lib/computed.js.map +1 -1
  75. package/dist/esm/lib/dispose.js +104 -78
  76. package/dist/esm/lib/dispose.js.map +1 -1
  77. package/dist/esm/lib/dom.js +38 -18
  78. package/dist/esm/lib/dom.js.map +1 -1
  79. package/dist/esm/lib/domComponent.js +65 -0
  80. package/dist/esm/lib/domComponent.js.map +1 -1
  81. package/dist/esm/lib/domComputed.js +10 -7
  82. package/dist/esm/lib/domComputed.js.map +1 -1
  83. package/dist/esm/lib/domDispose.js +26 -11
  84. package/dist/esm/lib/domDispose.js.map +1 -1
  85. package/dist/esm/lib/domForEach.js +3 -2
  86. package/dist/esm/lib/domForEach.js.map +1 -1
  87. package/dist/esm/lib/domImpl.js +26 -7
  88. package/dist/esm/lib/domImpl.js.map +1 -1
  89. package/dist/esm/lib/domMethods.js +77 -35
  90. package/dist/esm/lib/domMethods.js.map +1 -1
  91. package/dist/esm/lib/domevent.js +84 -59
  92. package/dist/esm/lib/domevent.js.map +1 -1
  93. package/dist/esm/lib/emit.js +67 -53
  94. package/dist/esm/lib/emit.js.map +1 -1
  95. package/dist/esm/lib/kowrap.js +5 -2
  96. package/dist/esm/lib/kowrap.js.map +1 -1
  97. package/dist/esm/lib/obsArray.js +82 -50
  98. package/dist/esm/lib/obsArray.js.map +1 -1
  99. package/dist/esm/lib/observable.js +26 -15
  100. package/dist/esm/lib/observable.js.map +1 -1
  101. package/dist/esm/lib/pureComputed.js +15 -18
  102. package/dist/esm/lib/pureComputed.js.map +1 -1
  103. package/dist/esm/lib/styled.js +24 -77
  104. package/dist/esm/lib/styled.js.map +1 -1
  105. package/dist/esm/lib/subscribe.js +27 -36
  106. package/dist/esm/lib/subscribe.js.map +1 -1
  107. package/dist/esm/lib/util.js +1 -0
  108. package/dist/esm/lib/util.js.map +1 -1
  109. package/dist/esm/lib/widgets/input.js +3 -1
  110. package/dist/esm/lib/widgets/input.js.map +1 -1
  111. package/dist/esm/lib/widgets/select.js +3 -1
  112. package/dist/esm/lib/widgets/select.js.map +1 -1
  113. package/dist/grain-full.debug.js +2146 -3062
  114. package/dist/grain-full.debug.js.map +7 -0
  115. package/dist/grain-full.min.js +6 -2
  116. package/dist/grain-full.min.js.map +7 -1
  117. package/lib/binding.ts +9 -2
  118. package/lib/computed.ts +56 -56
  119. package/lib/dispose.ts +110 -85
  120. package/lib/dom.ts +39 -20
  121. package/lib/domComponent.ts +66 -57
  122. package/lib/domComputed.ts +29 -19
  123. package/lib/domDispose.ts +28 -11
  124. package/lib/domForEach.ts +7 -3
  125. package/lib/domImpl.ts +30 -7
  126. package/lib/domMethods.ts +101 -46
  127. package/lib/domevent.ts +85 -60
  128. package/lib/emit.ts +64 -50
  129. package/lib/kowrap.ts +5 -2
  130. package/lib/obsArray.ts +89 -54
  131. package/lib/observable.ts +26 -15
  132. package/lib/pureComputed.ts +16 -22
  133. package/lib/styled.ts +85 -71
  134. package/lib/subscribe.ts +41 -45
  135. package/lib/util.ts +1 -0
  136. package/lib/widgets/input.ts +3 -1
  137. package/lib/widgets/select.ts +3 -1
  138. package/package.json +38 -27
@@ -1,35 +1,3 @@
1
- /**
2
- * ObsArray extends a plain Observable to allow for more efficient observation of array changes.
3
- *
4
- * As for any array-valued Observable, when the contents of the observed array changes, the
5
- * listeners get called with new and previous values which are the same array. For simple changes,
6
- * such as those made with .push() and .splice() methods, ObsArray allows for more efficient
7
- * handling of the change by calling listeners with splice info in the third argument.
8
- *
9
- * This module also provides computedArray(), which allows mapping each item of an ObsArray
10
- * through a function, passing through splice info for efficient handling of small changes. It
11
- * also allows mapping an observable or a computed whose value is an ObsArray.
12
- *
13
- * There is no need or benefit in using computedArray() if you have a computed() that returns a
14
- * plain array. It is specifically for the case when you want to preserve the efficiency of
15
- * ObsArray when you map its values.
16
- *
17
- * Both ObsArray and ComputedArray may be used with disposable elements as their owners. E.g.
18
- *
19
- * const arr = obsArray<D>();
20
- * arr.push(D.create(arr, "x"), D.create(arr, "y"));
21
- * arr.pop(); // Element "y" gets disposed.
22
- * arr.dispose(); // Element "x" gets disposed.
23
- *
24
- * const values = obsArray<string>();
25
- * const compArr = computedArray<D>(values, (val, i, compArr) => D.create(compArr, val));
26
- * values.push("foo", "bar"); // D("foo") and D("bar") get created
27
- * values.pop(); // D("bar") gets disposed.
28
- * compArr.dispose(); // D("foo") gets disposed.
29
- *
30
- * Note that only the pattern above works: obsArray (or compArray) may only be used to take
31
- * ownership of those disposables that are added to it as array elements.
32
- */
33
1
  import { IDisposable, IDisposableOwnerT } from './dispose';
34
2
  import { Listener } from './emit';
35
3
  import { BaseObservable, Observable } from './observable';
@@ -37,49 +5,85 @@ import { BaseObservable, Observable } from './observable';
37
5
  * Either an observable or a plain array of T. This is useful for functions like dom.forEach()
38
6
  * which are convenient to have available for both.
39
7
  */
40
- export declare type MaybeObsArray<T> = BaseObservable<T[]> | T[];
8
+ export type MaybeObsArray<T> = BaseObservable<T[]> | T[];
41
9
  /**
42
10
  * Info about a modification to ObsArray contents. It is included as a third argument to change
43
11
  * listeners when available. When not available, listeners should assume that the array changed
44
12
  * completely.
45
13
  */
46
14
  export interface IObsArraySplice<T> {
47
- start: number;
15
+ start: number; /** asdf */
48
16
  numAdded: number;
49
17
  deleted: T[];
50
18
  }
51
- export declare type ISpliceListener<T, C> = (this: C, val: T[], prev: T[], change?: IObsArraySplice<T>) => void;
19
+ export type ISpliceListener<T, C> = (this: C, val: T[], prev: T[], change?: IObsArraySplice<T>) => void;
52
20
  /**
53
- * ObsArray<T> is essentially an array-valued observable. The main difference is that it may be
21
+ * `ObsArray<T>` is essentially an array-valued observable. It extends a plain Observable to allow
22
+ * for more efficient observation of array changes. It also may be
54
23
  * used as an owner for disposable array elements.
24
+ *
25
+ * As for any array-valued `Observable`, when the contents of the observed array changes, the
26
+ * listeners get called with new and previous values which are the same array. For simple changes,
27
+ * such as those made with `.push()` and `.splice()` methods, `ObsArray` allows for more efficient
28
+ * handling of the change by calling listeners with splice info in the third argument.
29
+ *
30
+ * `ObsArray` may be used with disposable elements as their owner. E.g.
31
+ * ```ts
32
+ * const arr = obsArray<D>();
33
+ * arr.push(D.create(arr, "x"), D.create(arr, "y"));
34
+ * arr.pop(); // Element "y" gets disposed.
35
+ * arr.dispose(); // Element "x" gets disposed.
36
+ * ```
37
+ *
38
+ * Note that only the pattern above works: `obsArray` may only be used to take
39
+ * ownership of those disposables that are added to it as array elements.
55
40
  */
56
41
  export declare class ObsArray<T> extends BaseObservable<T[]> {
57
42
  private _ownedItems?;
43
+ /**
44
+ * Adds a callback to listen to changes in the observable. In case of `ObsArray`, the listener
45
+ * gets additional information.
46
+ */
58
47
  addListener(callback: ISpliceListener<T, void>): Listener;
59
48
  addListener<C>(callback: ISpliceListener<T, C>, context: C): Listener;
49
+ /**
50
+ * Take ownership of an item added to this array. This should _only_ be used for array elements,
51
+ * not any unrelated items.
52
+ */
60
53
  autoDispose(value: T & IDisposable): T & IDisposable;
54
+ /** @override */
61
55
  dispose(): void;
56
+ /** @internal */
62
57
  protected _setWithSplice(value: T[], splice: IObsArraySplice<T>): void;
58
+ /** @internal */
63
59
  protected _disposeOwned(splice?: IObsArraySplice<T>): void;
64
60
  }
65
61
  /**
66
- * MutableObsArray<T> adds array-like mutation methods which emit events with splice info, to
67
- * allow more efficient processing of such changes. It is created with obsArray<T>().
62
+ * `MutableObsArray<T>` adds array-like mutation methods which emit events with splice info, to
63
+ * allow more efficient processing of such changes. It is created with `obsArray<T>()`.
68
64
  */
69
65
  export declare class MutableObsArray<T> extends ObsArray<T> {
66
+ /** Appends elements to the end and returns the new length (like `Array#push`). */
70
67
  push(...args: T[]): number;
68
+ /** Removes and returns the last element (like `Array#pop`). */
71
69
  pop(): T | undefined;
70
+ /** Prepends elements to the start and returns the new length (like `Array#unshift`). */
72
71
  unshift(...args: T[]): number;
72
+ /** Removes and returns the first element (like `Array#shift`). */
73
73
  shift(): T | undefined;
74
+ /**
75
+ * Removes and/or inserts elements at a given index and returns the removed elements (like
76
+ * `Array#splice`).
77
+ */
74
78
  splice(start: number, deleteCount?: number, ...newValues: T[]): T[];
75
79
  }
76
80
  /**
77
81
  * Creates a new MutableObsArray with an optional initial value, defaulting to the empty array.
78
- * It is essentially the same as observable<T[]>, but with array-like mutation methods.
82
+ * It is essentially the same as `observable<T[]>`, but with array-like mutation methods.
79
83
  */
80
84
  export declare function obsArray<T>(value?: T[]): MutableObsArray<T>;
81
85
  /**
82
- * See computedArray() below for documentation.
86
+ * See [`computedArray()`](#computedArray) for documentation.
83
87
  */
84
88
  export declare class ComputedArray<T, U> extends ObsArray<U> {
85
89
  private _mapper;
@@ -88,6 +92,7 @@ export declare class ComputedArray<T, U> extends ObsArray<U> {
88
92
  private _listener?;
89
93
  private _lastSplice?;
90
94
  constructor(obsArr: BaseObservable<T[]> | Observable<BaseObservable<T[]>>, _mapper: (item: T, index: number, arr: ComputedArray<T, U>) => U);
95
+ /** @internal */
91
96
  dispose(): void;
92
97
  private _syncMap;
93
98
  private _unsync;
@@ -96,25 +101,43 @@ export declare class ComputedArray<T, U> extends ObsArray<U> {
96
101
  private _recordChange;
97
102
  }
98
103
  /**
99
- * Returns an ObsArray that maps all elements of the passed-in ObsArray through a mapper function.
100
- * Also accepts an observable (e.g. a computed) whose value is an ObsArray. Usage:
101
- *
102
- * computedArray(obsArray, mapper)
103
- *
104
- * The result is entirely analogous to:
104
+ * Returns an `ObsArray` that maps all elements of the passed-in `ObsArray` through a mapper
105
+ * function. Also accepts an observable (e.g. a computed) whose value is an `ObsArray`.
106
+ * ```ts
107
+ * computedArray(obsArray, mapper)
108
+ * ```
105
109
  *
106
- * computed((use) => use(obsArray).map(mapper)) // for ObsArray
107
- * computed((use) => use(use(obsArray)).map(mapper)) // for Observable<ObsArray>
110
+ * The result is analogous to:
111
+ * ```ts
112
+ * computed((use) => use(obsArray).map(mapper)) // for ObsArray
113
+ * computed((use) => use(use(obsArray)).map(mapper)) // for Observable<ObsArray>
114
+ * ```
108
115
  *
109
- * The benefit of computedArray() is that a small change to the source array (e.g. one item
116
+ * The benefit of `computedArray()` is that a small change to the source array (e.g. one item
110
117
  * added or removed), causes a small change to the mapped array, rather than a full rebuild.
111
118
  *
112
- * This is useful with an ObsArray or with an observable whose value is an ObsArray, and also
113
- * when the computed array owns its disposable items.
119
+ * This is useful with an `ObsArray` or with an observable whose value is an `ObsArray`, and also
120
+ * when the computed array's items are disposable and it owns them.
114
121
  *
115
- * Note that the mapper function is called with (item, index, array) as for a standard
116
- * array.map(), but that the index is only accurate at the time of the call, and will stop
122
+ * There is no need or benefit to using `computedArray()` if you have a `computed()` that returns
123
+ * a plain array. It is specifically for the case when you want to preserve the efficiency of
124
+ * `ObsArray` when you map its values.
125
+ *
126
+ * Note that the mapper function is called with `(item, index, array)` as for a standard
127
+ * `array.map()`, but that the index is only accurate at the time of the call, and will stop
117
128
  * reflecting the true index if more items are inserted into the array later.
129
+ *
130
+ * As with `ObsArray`, a `ComputedArray` may be used with disposable elements as their owners. E.g.
131
+ * ```ts
132
+ * const values = obsArray<string>();
133
+ * const compArr = computedArray<D>(values, (val, i, compArr) => D.create(compArr, val));
134
+ * values.push("foo", "bar"); // D("foo") and D("bar") get created
135
+ * values.pop(); // D("bar") gets disposed.
136
+ * compArr.dispose(); // D("foo") gets disposed.
137
+ * ```
138
+ *
139
+ * Note that only the pattern above works: obsArray (or compArray) may only be used to take
140
+ * ownership of those disposables that are added to it as array elements.
118
141
  */
119
142
  export declare function computedArray<T, U>(obsArr: BaseObservable<T[]> | Observable<BaseObservable<T[]>>, mapper: (item: T, index: number, arr: ComputedArray<T, U>) => U): ObsArray<U>;
120
143
  /**
@@ -128,13 +151,28 @@ export declare function computedArray<T, U>(obsArr: BaseObservable<T[]> | Observ
128
151
  * observable will not be adjusted as the array changes, except to keep it valid.
129
152
  */
130
153
  export declare function makeLiveIndex<T>(owner: IDisposableOwnerT<LiveIndex> | null, obsArr: ObsArray<T>, initialIndex?: number): LiveIndex;
154
+ /**
155
+ * An Observable that represents an index into an `ObsArray`, clamped to be in the valid range.
156
+ */
131
157
  export declare class LiveIndex extends Observable<number | null> {
132
158
  private _obsArray;
133
159
  private _listener;
134
160
  private _isLive;
135
161
  constructor(_obsArray: ObsArray<any>, initialIndex?: number);
162
+ /**
163
+ * Set the index, clamping it to a valid value.
164
+ */
136
165
  set(index: number | null): void;
166
+ /**
167
+ * Turn "liveness" on or off. While set to false, the observable will not be adjusted as the
168
+ * array changes, except to keep it valid.
169
+ *
170
+ * @privateRemarks
171
+ * Note that this feature comes from a rather obscure need, and it would be better if something
172
+ * similar were possible without making it an explicit feature.
173
+ */
137
174
  setLive(value: boolean): void;
175
+ /** @override */
138
176
  dispose(): void;
139
177
  private _onArrayChange;
140
178
  }
@@ -1,44 +1,29 @@
1
1
  "use strict";
2
- /**
3
- * ObsArray extends a plain Observable to allow for more efficient observation of array changes.
4
- *
5
- * As for any array-valued Observable, when the contents of the observed array changes, the
6
- * listeners get called with new and previous values which are the same array. For simple changes,
7
- * such as those made with .push() and .splice() methods, ObsArray allows for more efficient
8
- * handling of the change by calling listeners with splice info in the third argument.
9
- *
10
- * This module also provides computedArray(), which allows mapping each item of an ObsArray
11
- * through a function, passing through splice info for efficient handling of small changes. It
12
- * also allows mapping an observable or a computed whose value is an ObsArray.
13
- *
14
- * There is no need or benefit in using computedArray() if you have a computed() that returns a
15
- * plain array. It is specifically for the case when you want to preserve the efficiency of
16
- * ObsArray when you map its values.
17
- *
18
- * Both ObsArray and ComputedArray may be used with disposable elements as their owners. E.g.
19
- *
20
- * const arr = obsArray<D>();
21
- * arr.push(D.create(arr, "x"), D.create(arr, "y"));
22
- * arr.pop(); // Element "y" gets disposed.
23
- * arr.dispose(); // Element "x" gets disposed.
24
- *
25
- * const values = obsArray<string>();
26
- * const compArr = computedArray<D>(values, (val, i, compArr) => D.create(compArr, val));
27
- * values.push("foo", "bar"); // D("foo") and D("bar") get created
28
- * values.pop(); // D("bar") gets disposed.
29
- * compArr.dispose(); // D("foo") gets disposed.
30
- *
31
- * Note that only the pattern above works: obsArray (or compArray) may only be used to take
32
- * ownership of those disposables that are added to it as array elements.
33
- */
34
2
  Object.defineProperty(exports, "__esModule", { value: true });
35
3
  exports.LiveIndex = exports.makeLiveIndex = exports.computedArray = exports.ComputedArray = exports.obsArray = exports.MutableObsArray = exports.ObsArray = void 0;
36
4
  const dispose_1 = require("./dispose");
37
5
  const observable_1 = require("./observable");
38
6
  const subscribe_1 = require("./subscribe");
39
7
  /**
40
- * ObsArray<T> is essentially an array-valued observable. The main difference is that it may be
8
+ * `ObsArray<T>` is essentially an array-valued observable. It extends a plain Observable to allow
9
+ * for more efficient observation of array changes. It also may be
41
10
  * used as an owner for disposable array elements.
11
+ *
12
+ * As for any array-valued `Observable`, when the contents of the observed array changes, the
13
+ * listeners get called with new and previous values which are the same array. For simple changes,
14
+ * such as those made with `.push()` and `.splice()` methods, `ObsArray` allows for more efficient
15
+ * handling of the change by calling listeners with splice info in the third argument.
16
+ *
17
+ * `ObsArray` may be used with disposable elements as their owner. E.g.
18
+ * ```ts
19
+ * const arr = obsArray<D>();
20
+ * arr.push(D.create(arr, "x"), D.create(arr, "y"));
21
+ * arr.pop(); // Element "y" gets disposed.
22
+ * arr.dispose(); // Element "x" gets disposed.
23
+ * ```
24
+ *
25
+ * Note that only the pattern above works: `obsArray` may only be used to take
26
+ * ownership of those disposables that are added to it as array elements.
42
27
  */
43
28
  class ObsArray extends observable_1.BaseObservable {
44
29
  constructor() {
@@ -48,6 +33,10 @@ class ObsArray extends observable_1.BaseObservable {
48
33
  addListener(callback, optContext) {
49
34
  return super.addListener(callback, optContext);
50
35
  }
36
+ /**
37
+ * Take ownership of an item added to this array. This should _only_ be used for array elements,
38
+ * not any unrelated items.
39
+ */
51
40
  autoDispose(value) {
52
41
  if (!this._ownedItems) {
53
42
  this._ownedItems = new Set();
@@ -55,6 +44,7 @@ class ObsArray extends observable_1.BaseObservable {
55
44
  this._ownedItems.add(value);
56
45
  return value;
57
46
  }
47
+ /** @override */
58
48
  dispose() {
59
49
  if (this._ownedItems) {
60
50
  for (const item of this.get()) {
@@ -66,9 +56,11 @@ class ObsArray extends observable_1.BaseObservable {
66
56
  }
67
57
  super.dispose();
68
58
  }
59
+ /** @internal */
69
60
  _setWithSplice(value, splice) {
70
61
  return this._setWithArg(value, splice);
71
62
  }
63
+ /** @internal */
72
64
  _disposeOwned(splice) {
73
65
  if (!this._ownedItems) {
74
66
  return;
@@ -98,10 +90,11 @@ class ObsArray extends observable_1.BaseObservable {
98
90
  }
99
91
  exports.ObsArray = ObsArray;
100
92
  /**
101
- * MutableObsArray<T> adds array-like mutation methods which emit events with splice info, to
102
- * allow more efficient processing of such changes. It is created with obsArray<T>().
93
+ * `MutableObsArray<T>` adds array-like mutation methods which emit events with splice info, to
94
+ * allow more efficient processing of such changes. It is created with `obsArray<T>()`.
103
95
  */
104
96
  class MutableObsArray extends ObsArray {
97
+ /** Appends elements to the end and returns the new length (like `Array#push`). */
105
98
  push(...args) {
106
99
  const value = this.get();
107
100
  const start = value.length;
@@ -109,6 +102,7 @@ class MutableObsArray extends ObsArray {
109
102
  this._setWithSplice(value, { start, numAdded: args.length, deleted: [] });
110
103
  return newLen;
111
104
  }
105
+ /** Removes and returns the last element (like `Array#pop`). */
112
106
  pop() {
113
107
  const value = this.get();
114
108
  if (value.length === 0) {
@@ -118,12 +112,14 @@ class MutableObsArray extends ObsArray {
118
112
  this._setWithSplice(value, { start: value.length, numAdded: 0, deleted: [ret] });
119
113
  return ret;
120
114
  }
115
+ /** Prepends elements to the start and returns the new length (like `Array#unshift`). */
121
116
  unshift(...args) {
122
117
  const value = this.get();
123
118
  const newLen = value.unshift(...args);
124
119
  this._setWithSplice(value, { start: 0, numAdded: args.length, deleted: [] });
125
120
  return newLen;
126
121
  }
122
+ /** Removes and returns the first element (like `Array#shift`). */
127
123
  shift() {
128
124
  const value = this.get();
129
125
  if (value.length === 0) {
@@ -133,6 +129,10 @@ class MutableObsArray extends ObsArray {
133
129
  this._setWithSplice(value, { start: 0, numAdded: 0, deleted: [ret] });
134
130
  return ret;
135
131
  }
132
+ /**
133
+ * Removes and/or inserts elements at a given index and returns the removed elements (like
134
+ * `Array#splice`).
135
+ */
136
136
  splice(start, deleteCount = Infinity, ...newValues) {
137
137
  const value = this.get();
138
138
  const len = value.length;
@@ -145,7 +145,7 @@ class MutableObsArray extends ObsArray {
145
145
  exports.MutableObsArray = MutableObsArray;
146
146
  /**
147
147
  * Creates a new MutableObsArray with an optional initial value, defaulting to the empty array.
148
- * It is essentially the same as observable<T[]>, but with array-like mutation methods.
148
+ * It is essentially the same as `observable<T[]>`, but with array-like mutation methods.
149
149
  */
150
150
  function obsArray(value = []) {
151
151
  return new MutableObsArray(value);
@@ -158,16 +158,17 @@ function isObsArray(val) {
158
158
  return Array.isArray(val.get());
159
159
  }
160
160
  /**
161
- * See computedArray() below for documentation.
161
+ * See [`computedArray()`](#computedArray) for documentation.
162
162
  */
163
163
  class ComputedArray extends ObsArray {
164
164
  constructor(obsArr, _mapper) {
165
165
  super([]);
166
166
  this._mapper = _mapper;
167
167
  this._sub = isObsArray(obsArr) ?
168
- subscribe_1.subscribe(obsArr, (use) => this._syncMap(obsArr)) :
169
- subscribe_1.subscribe(obsArr, (use, obsArrayValue) => { use(obsArrayValue); return this._syncMap(obsArrayValue); });
168
+ (0, subscribe_1.subscribe)(obsArr, (use) => this._syncMap(obsArr)) :
169
+ (0, subscribe_1.subscribe)(obsArr, (use, obsArrayValue) => { use(obsArrayValue); return this._syncMap(obsArrayValue); });
170
170
  }
171
+ /** @internal */
171
172
  dispose() {
172
173
  this._unsync();
173
174
  this._sub.dispose();
@@ -224,25 +225,43 @@ class ComputedArray extends ObsArray {
224
225
  }
225
226
  exports.ComputedArray = ComputedArray;
226
227
  /**
227
- * Returns an ObsArray that maps all elements of the passed-in ObsArray through a mapper function.
228
- * Also accepts an observable (e.g. a computed) whose value is an ObsArray. Usage:
229
- *
230
- * computedArray(obsArray, mapper)
231
- *
232
- * The result is entirely analogous to:
228
+ * Returns an `ObsArray` that maps all elements of the passed-in `ObsArray` through a mapper
229
+ * function. Also accepts an observable (e.g. a computed) whose value is an `ObsArray`.
230
+ * ```ts
231
+ * computedArray(obsArray, mapper)
232
+ * ```
233
233
  *
234
- * computed((use) => use(obsArray).map(mapper)) // for ObsArray
235
- * computed((use) => use(use(obsArray)).map(mapper)) // for Observable<ObsArray>
234
+ * The result is analogous to:
235
+ * ```ts
236
+ * computed((use) => use(obsArray).map(mapper)) // for ObsArray
237
+ * computed((use) => use(use(obsArray)).map(mapper)) // for Observable<ObsArray>
238
+ * ```
236
239
  *
237
- * The benefit of computedArray() is that a small change to the source array (e.g. one item
240
+ * The benefit of `computedArray()` is that a small change to the source array (e.g. one item
238
241
  * added or removed), causes a small change to the mapped array, rather than a full rebuild.
239
242
  *
240
- * This is useful with an ObsArray or with an observable whose value is an ObsArray, and also
241
- * when the computed array owns its disposable items.
243
+ * This is useful with an `ObsArray` or with an observable whose value is an `ObsArray`, and also
244
+ * when the computed array's items are disposable and it owns them.
242
245
  *
243
- * Note that the mapper function is called with (item, index, array) as for a standard
244
- * array.map(), but that the index is only accurate at the time of the call, and will stop
246
+ * There is no need or benefit to using `computedArray()` if you have a `computed()` that returns
247
+ * a plain array. It is specifically for the case when you want to preserve the efficiency of
248
+ * `ObsArray` when you map its values.
249
+ *
250
+ * Note that the mapper function is called with `(item, index, array)` as for a standard
251
+ * `array.map()`, but that the index is only accurate at the time of the call, and will stop
245
252
  * reflecting the true index if more items are inserted into the array later.
253
+ *
254
+ * As with `ObsArray`, a `ComputedArray` may be used with disposable elements as their owners. E.g.
255
+ * ```ts
256
+ * const values = obsArray<string>();
257
+ * const compArr = computedArray<D>(values, (val, i, compArr) => D.create(compArr, val));
258
+ * values.push("foo", "bar"); // D("foo") and D("bar") get created
259
+ * values.pop(); // D("bar") gets disposed.
260
+ * compArr.dispose(); // D("foo") gets disposed.
261
+ * ```
262
+ *
263
+ * Note that only the pattern above works: obsArray (or compArray) may only be used to take
264
+ * ownership of those disposables that are added to it as array elements.
246
265
  */
247
266
  function computedArray(obsArr, mapper) {
248
267
  return new ComputedArray(obsArr, mapper);
@@ -259,9 +278,12 @@ exports.computedArray = computedArray;
259
278
  * observable will not be adjusted as the array changes, except to keep it valid.
260
279
  */
261
280
  function makeLiveIndex(owner, obsArr, initialIndex = 0) {
262
- return dispose_1.setDisposeOwner(owner, new LiveIndex(obsArr, initialIndex));
281
+ return (0, dispose_1.setDisposeOwner)(owner, new LiveIndex(obsArr, initialIndex));
263
282
  }
264
283
  exports.makeLiveIndex = makeLiveIndex;
284
+ /**
285
+ * An Observable that represents an index into an `ObsArray`, clamped to be in the valid range.
286
+ */
265
287
  class LiveIndex extends observable_1.Observable {
266
288
  constructor(_obsArray, initialIndex = 0) {
267
289
  super(null);
@@ -270,16 +292,26 @@ class LiveIndex extends observable_1.Observable {
270
292
  this.set(initialIndex);
271
293
  this._listener = _obsArray.addListener(this._onArrayChange, this);
272
294
  }
295
+ /**
296
+ * Set the index, clamping it to a valid value.
297
+ */
273
298
  set(index) {
274
299
  // Clamp to [0, len) range of the observable array.
275
300
  const len = this._obsArray.get().length;
276
301
  super.set(len === 0 ? null : Math.max(0, Math.min(len - 1, index || 0)));
277
302
  }
278
- // Note that this feature comes from a rather obscure need, and it would be better if something
279
- // similar were possible without making it an explicit feature.
303
+ /**
304
+ * Turn "liveness" on or off. While set to false, the observable will not be adjusted as the
305
+ * array changes, except to keep it valid.
306
+ *
307
+ * @privateRemarks
308
+ * Note that this feature comes from a rather obscure need, and it would be better if something
309
+ * similar were possible without making it an explicit feature.
310
+ */
280
311
  setLive(value) {
281
312
  this._isLive = value;
282
313
  }
314
+ /** @override */
283
315
  dispose() {
284
316
  this._listener.dispose();
285
317
  super.dispose();
@@ -1 +1 @@
1
- {"version":3,"file":"obsArray.js","sourceRoot":"","sources":["../../../lib/obsArray.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;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Aa,EAAE,MAA2B;QACjF,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,GAAG,CACN,GAAG,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7B,wDAAwD;YACxD,IAAI,CAAC,OAAO,IAAI,GAAG,IAAI,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBAC7G,2EAA2E;gBAC3E,IAAI,CAAC,OAAO,IAAI,GAAG,IAAI,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;oBACxF,GAAG,CAAC,CAAC;IACT,CAAC;CACF;AA/CD,8BA+CC"}
@@ -24,23 +24,23 @@ import { DepItem } from './_computed_queue';
24
24
  import { IDisposable, IDisposableOwnerT } from './dispose';
25
25
  import { Listener } from './emit';
26
26
  export { bundleChanges } from './_computed_queue';
27
+ /**
28
+ * Base class for several variants of observable values.
29
+ */
27
30
  export declare class BaseObservable<T> {
28
31
  private _onChange;
29
32
  private _value;
30
- /**
31
- * Internal constructor for an Observable. You should use observable() function instead.
32
- */
33
33
  constructor(value: T);
34
34
  /**
35
35
  * Returns the value of the observable. It is fast and does not create a subscription.
36
36
  * (It is similar to knockout's peek()).
37
- * @returns {Object} The current value of the observable.
37
+ * @returns The current value of the observable.
38
38
  */
39
39
  get(): T;
40
40
  /**
41
41
  * Sets the value of the observable. If the value differs from the previously set one, then
42
42
  * listeners to this observable will get called with (newValue, oldValue) as arguments.
43
- * @param {Object} value: The new value to set.
43
+ * @param value - The new value to set.
44
44
  */
45
45
  set(value: T): void;
46
46
  /**
@@ -49,9 +49,9 @@ export declare class BaseObservable<T> {
49
49
  setAndTrigger(value: T): void;
50
50
  /**
51
51
  * Adds a callback to listen to changes in the observable.
52
- * @param {Function} callback: Function, called on changes with (newValue, oldValue) arguments.
53
- * @param {Object} optContext: Context for the function.
54
- * @returns {Listener} Listener object. Its dispose() method removes the callback.
52
+ * @param callback - Function, called on changes with (newValue, oldValue) arguments.
53
+ * @param optContext - Context for the function.
54
+ * @returns Listener object. Its dispose() method removes the callback.
55
55
  */
56
56
  addListener(callback: (val: T, prev: T) => void, optContext?: object): Listener;
57
57
  /**
@@ -61,7 +61,7 @@ export declare class BaseObservable<T> {
61
61
  /**
62
62
  * Sets a single callback to be called when a listener is added or removed. It overwrites any
63
63
  * previously-set such callback.
64
- * @param {Function} changeCB(hasListeners): Function to call after a listener is added or
64
+ * @param changeCB - Function to call after a listener is added or
65
65
  * removed. It's called with a boolean indicating whether this observable has any listeners.
66
66
  * Pass in `null` to unset the callback. Note that it can be called multiple times in a row
67
67
  * with hasListeners `true`.
@@ -70,6 +70,7 @@ export declare class BaseObservable<T> {
70
70
  /**
71
71
  * Used by subscriptions to keep track of dependencies. An observable that has dependnecies,
72
72
  * such as a computed observable, would override this method.
73
+ * @internal
73
74
  */
74
75
  _getDepItem(): DepItem | null;
75
76
  /**
@@ -80,14 +81,20 @@ export declare class BaseObservable<T> {
80
81
  * Returns whether this observable is disposed.
81
82
  */
82
83
  isDisposed(): boolean;
84
+ /** @internal */
83
85
  protected _disposeOwned(arg?: any): void;
84
86
  /**
85
87
  * Allow derived classes to emit change events with an additional third argument describing the
86
88
  * change. It always emits the event without checking for value equality.
89
+ * @internal
87
90
  */
88
91
  protected _setWithArg(value: T, arg: any): void;
89
92
  }
93
+ /**
94
+ * An Observable holds a value and allows subscribing to changes.
95
+ */
90
96
  export declare class Observable<T> extends BaseObservable<T> implements IDisposableOwnerT<T & IDisposable> {
97
+ /** @internal */
91
98
  static holder<T>(value: T & IDisposable): Observable<T>;
92
99
  /**
93
100
  * Creates a new Observable with the given initial value, and owned by owner.
@@ -104,25 +111,28 @@ export declare class Observable<T> extends BaseObservable<T> implements IDisposa
104
111
  * will dispose the owned value when it's set to another value, or when it itself is disposed.
105
112
  */
106
113
  autoDispose(value: T & IDisposable): T & IDisposable;
114
+ /** @internal */
107
115
  protected _disposeOwned(): void;
108
116
  }
109
117
  /**
110
118
  * Creates a new Observable with the initial value of optValue if given or undefined if omitted.
111
- * @param {Object} optValue: The initial value to set.
112
- * @returns {Observable} The newly created observable.
119
+ * @param optValue - The initial value to set.
120
+ * @returns The newly created observable.
113
121
  */
114
122
  export declare function observable<T>(value: T): Observable<T>;
115
123
  /**
116
124
  * Creates a new Observable with an initial disposable value owned by this observable, e.g.
117
- *
125
+ * ```
118
126
  * const obs = obsHolder<D>(D.create(null, ...args));
127
+ * ```
119
128
  *
120
- * This is needed because using simply observable<D>(value) would not cause the observable to take
129
+ * This is needed because using simply `observable<D>(value)` would not cause the observable to take
121
130
  * ownership of value (i.e. to dispose it later). This function is a less hacky equivalent to:
122
- *
131
+ * ```
123
132
  * const obs = observable<D>(null as any);
124
133
  * D.create(obs, ...args);
134
+ * ```
125
135
  *
126
- * To allow nulls, use observable<D|null>(null); then the obsHolder() constructor is not needed.
136
+ * To allow nulls, use `observable<D|null>(null)`; then the obsHolder() constructor is not needed.
127
137
  */
128
138
  export declare function obsHolder<T>(value: T & IDisposable): Observable<T>;