@fireflysemantics/slice 17.0.14 → 17.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/EStore.d.ts CHANGED
@@ -7,39 +7,46 @@ import { Slice } from './Slice';
7
7
  * This `todoFactory` code will be used to illustrate the API examples. The following
8
8
  * utilities are used in the tests and the API Typedoc examples contained here.
9
9
  * @example Utilities for API Examples
10
- ```
11
- export const enum TodoSliceEnum {
12
- COMPLETE = "Complete",
13
- INCOMPLETE = "Incomplete"
14
- }
15
-
16
- export class Todo {
17
- constructor(public complete: boolean, public title: string,public gid?:string, public id?:string) {}
18
- }
19
-
20
- export let todos = [new Todo(false, "You complete me!"), new Todo(true, "You completed me!")];
21
-
22
- export function todosFactory():Todo[] {
23
- return [new Todo(false, "You complete me!"), new Todo(true, "You completed me!")];
24
- }
25
- ```
10
+ * ```
11
+ * export const enum TodoSliceEnum {
12
+ * COMPLETE = "Complete",
13
+ * INCOMPLETE = "Incomplete"
14
+ * }
15
+ * export class Todo {
16
+ * constructor(
17
+ * public complete: boolean,
18
+ * public title: string,
19
+ * public gid?:string,
20
+ * public id?:string) {}
21
+ * }
22
+ *
23
+ * export let todos = [new Todo(false, "You complete me!"), new Todo(true, "You completed me!")];
24
+ *
25
+ * export function todosFactory():Todo[] {
26
+ * return [new Todo(false, "You complete me!"), new Todo(true, "You completed me!")];
27
+ * }
28
+ * ```
26
29
  */
27
30
  export declare class EStore<E> extends AbstractStore<E> {
28
31
  /**
29
32
  * Store constructor (Initialization with element is optional)
30
33
  *
31
34
  * perform initial notification to all observers,
32
- * such that function like {@link combineLatest}{}
35
+ * such that functions like {@link combineLatest}{}
33
36
  * will execute at least once.
34
- * @param entities
35
- * @example Dynamic `EStore<Todo>` Creation
36
- ```
37
- // Initialize the Store
38
- let store: EStore<Todo> = new EStore<Todo>(todosFactory());
39
- ```*/
37
+ *
38
+ * @param entities The entities to initialize the store with.
39
+ * @param config The optional configuration instance.
40
+ *
41
+ * @example EStore<Todo> Creation
42
+ * ```
43
+ * // Initialize the Store
44
+ * let store: EStore<Todo> = new EStore<Todo>(todosFactory());
45
+ * ```
46
+ */
40
47
  constructor(entities?: E[], config?: StoreConfig);
41
48
  /**
42
- * Calls complete on all {@link BehaviorSubject} instances.
49
+ * Calls complete on all EStore {@link ReplaySubject} instances.
43
50
  *
44
51
  * Call destroy when disposing of the store.
45
52
  */
@@ -51,16 +58,15 @@ export declare class EStore<E> extends AbstractStore<E> {
51
58
  * it will be deleted. If the store
52
59
  * does not contains the entity,
53
60
  * it is added.
54
- * @param e
55
- * @example Toggle the `Todo` instance
56
- ```
57
- estore.post(todo);
58
- // Remove todo
59
- estore.toggle(todo);
60
- // Add it back
61
- estore.toggle(todo);
62
-
63
- ```
61
+ * @param e The entity to toggle
62
+ * @example Toggle the Todo instance
63
+ * ```
64
+ * estore.post(todo);
65
+ * // Remove todo
66
+ * estore.toggle(todo);
67
+ * // Add it back
68
+ * estore.toggle(todo);
69
+ * ```
64
70
  */
65
71
  toggle(e: E): void;
66
72
  /**
@@ -84,26 +90,26 @@ export declare class EStore<E> extends AbstractStore<E> {
84
90
  * change detection in the event that it maintains
85
91
  * a reference to the `active` state `Map` instance.
86
92
  *
87
- * @example Add a `todo1` and `todo2` as active
88
- ```
89
- addActive(todo1);
90
- addActive(todo2);
91
- ```
93
+ * @example Add todo1 and todo2 as active
94
+ * ```
95
+ * addActive(todo1);
96
+ * addActive(todo2);
97
+ * ```
92
98
  */
93
99
  addActive(e: E): void;
94
100
  /**
95
- * Delete an entity as active.
101
+ * Delete an active entity.
96
102
  *
97
103
  * Also we clone the map prior to broadcasting it with
98
104
  * `notifyActive` to make sure we will trigger Angular
99
105
  * change detection in the event that it maintains
100
106
  * a reference to the `active` state `Map` instance.
101
107
  *
102
- * @example Mark a `todo` instance as active
103
- ```
104
- deleteActive(todo1);
105
- deleteActive(todo2);
106
- ```
108
+ * @example Remove todo1 and todo2 as active entities
109
+ * ```
110
+ * deleteActive(todo1);
111
+ * deleteActive(todo2);
112
+ * ```
107
113
  */
108
114
  deleteActive(e: E): void;
109
115
  /**
@@ -114,20 +120,20 @@ export declare class EStore<E> extends AbstractStore<E> {
114
120
  * change detection in the event that it maintains
115
121
  * a reference to the `active` state `Map` instance.
116
122
  *
117
- * @example Mark a `todo` instance as active
118
- ```
119
- deleteActive(todo1);
120
- deleteActive(todo2);
121
- ```
123
+ * @example Clear active todo instances
124
+ * ```
125
+ * store.clearActive();
126
+ * ```
122
127
  */
123
128
  clearActive(): void;
124
129
  /**
125
- * Observe the active entity.
130
+ * Observe the active entities.
131
+ *
126
132
  * @example
127
- <pre>
128
- let active$ = source.observeActive();
129
- </pre>
130
- */
133
+ * ```
134
+ * let active$ = store.observeActive();
135
+ * ```
136
+ */
131
137
  observeActive(): Observable<Map<string, E>>;
132
138
  /**
133
139
  * Observe the active entity.
@@ -169,24 +175,81 @@ export declare class EStore<E> extends AbstractStore<E> {
169
175
  set loading(loading: boolean);
170
176
  /**
171
177
  * @return A snapshot of the loading state.
178
+ * @example Create a reference to the loading state
179
+ * ```
180
+ * const loading:boolean = todoStore.loading;
181
+ * ```
172
182
  */
173
183
  get loading(): boolean;
174
184
  /**
175
185
  * Observe loading.
186
+ *
187
+ * Note that this obverable piped through
188
+ * `takeWhile(v->v, true), such that it will
189
+ * complete after each emission.
190
+ *
191
+ * See:
192
+ * https://fireflysemantics.medium.com/waiting-on-estore-to-load-8dcbe161613c
193
+ *
194
+ * For more details.
195
+ * Also note that v=>v is the same as v=>v!=false
196
+ *
176
197
  * @example
177
- <pre>
178
- let loading$ = source.observeLoading();
179
- </pre>
180
-
181
- Note that this obverable piped through
182
- `takeWhile(v->v, true), such that it will
183
- complete after each emission.
184
-
185
- See:
186
- https://medium.com/@ole.ersoy/waiting-on-estore-to-load-8dcbe161613c
187
-
188
- For more details.
189
- */
198
+ * ```
199
+ * const observeLoadingHandler: Observer<boolean> = {
200
+ * complete: () => {
201
+ * console.log(`Data Loaded and Observable Marked as Complete`);
202
+ * }, // completeHandler
203
+ * error: () => {
204
+ * console.log(`Any Errors?`);
205
+ * }, // errorHandler
206
+ * next: (l) => {
207
+ * console.log(`Data loaded and loading is ${l}`);
208
+ * },
209
+ * };
210
+ *
211
+ * const observeLoadingResubscribeHandler: Observer<boolean> = {
212
+ * complete: () => {
213
+ * console.log(`Data Loaded and Resubscribe Observable Marked as Complete`);
214
+ * }, // completeHandler
215
+ * error: () => {
216
+ * console.log(`Any Resubscribe Errors?`);
217
+ * }, // errorHandler
218
+ * next: (l) => {
219
+ * console.log(`Data loaded and resusbscribe loading value is ${l}`);
220
+ * },
221
+ * };
222
+ *
223
+ * const todoStore: EStore<Todo> = new EStore();
224
+ * //============================================
225
+ * // Loading is true by default
226
+ * //============================================
227
+ * console.log(`The initial value of loading is ${todoStore.loading}`);
228
+ * //============================================
229
+ * // Observe Loading
230
+ * //============================================
231
+ * let loading$: Observable<boolean> = todoStore.observeLoading();
232
+ * loading$.subscribe((l) => console.log(`The value of loading is ${l}`));
233
+ *
234
+ * todoStore.loading = false;
235
+ * loading$.subscribe(observeLoadingHandler);
236
+ * //============================================
237
+ * // The subscription no longer fires
238
+ * //============================================
239
+ * todoStore.loading = true;
240
+ * todoStore.loading = false;
241
+ *
242
+ * //============================================
243
+ * // The subscription no longer fires,
244
+ * // so if we want to observe loading again
245
+ * // resusbscribe.
246
+ * //============================================
247
+ * todoStore.loading = true;
248
+ * loading$ = todoStore.observeLoading();
249
+ * loading$.subscribe(observeLoadingResubscribeHandler);
250
+ * todoStore.loading = false;
251
+ * ```
252
+ */
190
253
  observeLoading(): Observable<boolean>;
191
254
  /**
192
255
  * Notfiies when loading has completed.
@@ -282,92 +345,95 @@ export declare class EStore<E> extends AbstractStore<E> {
282
345
  /**
283
346
  * Post (Add a new) element(s) to the store.
284
347
  * @param e An indiidual entity or an array of entities
285
- * @example Post a `todo`.
286
- ```
287
- store.post(todo);
288
- ```
348
+ * @example Post a Todo instance.
349
+ *
350
+ *```
351
+ * store.post(todo);
352
+ *```
289
353
  */
290
354
  post(e: E | E[]): void;
291
355
  /**
292
- * Post elements to the store.
356
+ * Post N entities to the store.
293
357
  * @param ...e
294
- * @example Post two `Todo` instances.
295
- ```
296
- store.post(todo1, todo2);
297
- ```
358
+ * @example Post two Todo instances.
359
+ * ```
360
+ * store.post(todo1, todo2);
361
+ * ```
298
362
  */
299
363
  postN(...e: E[]): void;
300
364
  /**
301
365
  * Post (Add) an array of elements to the store.
302
366
  * @param e
303
- * @example Post a `Todo` array.
304
- ```
305
- store.post([todo1, todo2]);
306
- ```
367
+ * @example Post a Todo array.
368
+ *
369
+ * ```
370
+ * store.post([todo1, todo2]);
371
+ * ```
307
372
  */
308
373
  postA(e: E[]): void;
309
374
  /**
310
- * Put (Update) an element.
375
+ * Put (Update) an entity.
311
376
  * @param e
312
377
  * @example Put a Todo instance.
313
- ```
314
- store.put(todo1);
315
- ```
378
+ * ```
379
+ * store.put(todo1);
380
+ * ```
316
381
  */
317
382
  put(e: E | E[]): void;
318
383
  /**
319
384
  * Put (Update) an element or add an element that was read from a persistence source
320
385
  * and thus already has an assigned global id`.
321
- * @param e
322
- * @example Put Todo instances.
323
- ```
324
- store.put(todo1, todo2);
325
- ```
386
+ * @param e The enetity instances to update.
387
+ * @example Put N Todo instances.
388
+ *
389
+ * ```
390
+ * store.put(todo1, todo2);
391
+ * ```
326
392
  */
327
393
  putN(...e: E[]): void;
328
394
  /**
329
- * Put (Update) the array of elements.
330
- * @param e
331
- * @example Put Todo instances.
332
- ```
333
- store.put([todo1, todo2]);
334
- ```
395
+ * Put (Update) the array of enntities.
396
+ * @param e The array of enntities to update
397
+ * @example Put an array of Todo instances.
398
+ * ```
399
+ * store.put([todo1, todo2]);
400
+ * ```
335
401
  */
336
402
  putA(e: E[]): void;
337
403
  /**
338
404
  * Delete (Update) the array of elements.
339
405
  * @param e
340
406
  * @example Delete todo1.
341
- ```
342
- store.delete(todo1]);
343
- ```
407
+ * ```
408
+ * store.delete(todo1]);
409
+ * ```
344
410
  */
345
411
  delete(e: E | E[]): void;
346
412
  /**
347
413
  * Delete N elements.
348
414
  * @param ...e
349
- * @example Put Todo instances.
350
- ```
351
- store.delete(todo1, todo2);
352
- ```
415
+ * @example Delete N Todo instance argument.
416
+ * ```
417
+ * store.deleteN(todo1, todo2);
418
+ * ```
353
419
  */
354
420
  deleteN(...e: E[]): void;
355
421
  /**
356
- * Delete N elements.
357
- * @param ...e
358
- * @example Put Todo instances.
359
- ```
360
- store.delete(todo1, todo2);
361
- ```
422
+ * Delete an array of elements.
423
+ * @param e The array of instances to be deleted
424
+ * @example Delete the array of Todo instances.
425
+ * ```
426
+ * store.deleteA([todo1, todo2]);
427
+ * ```
362
428
  */
363
429
  deleteA(e: E[]): void;
364
430
  /**
365
431
  * Delete elements by {@link Predicate}.
366
432
  * @param p The predicate.
367
- * @example Put Todo instances.
368
- ```
369
- store.delete(todo1, todo2);
370
- ```
433
+ * @example Delete the Todo instances.
434
+ * ```
435
+ * store.delete(todo1, todo2);
436
+ * ```
371
437
  */
372
438
  deleteP(p: Predicate<E>): void;
373
439
  /**
@@ -391,9 +457,9 @@ export declare class EStore<E> extends AbstractStore<E> {
391
457
  * send their own delta notification.
392
458
  *
393
459
  * @example Reset the store.
394
- ```
395
- store.reset();
396
- ```
460
+ * ```
461
+ * store.reset();
462
+ * ```
397
463
  */
398
464
  reset(): void;
399
465
  /**
package/lib/Slice.d.ts CHANGED
@@ -16,15 +16,15 @@ export declare class Slice<E> extends AbstractStore<E> {
16
16
  * @param eStore The EStore instance containing the elements considered for slicing
17
17
  *
18
18
  * @example
19
- <pre>
20
- //Empty slice
21
- new Slice<Todo>(Todo.COMPLETE, todo=>!todo.complete);
22
-
23
- //Initialized slice
24
- let todos = [new Todo(false, "You complete me!"),
25
- new Todo(true, "You completed me!")];
26
- new Slice<Todo>(Todo.COMPLETE, todo=>!todo.complete, todos);
27
- </pre>
19
+ * ```
20
+ * //Empty slice
21
+ * new Slice<Todo>(Todo.COMPLETE, todo=>!todo.complete);
22
+ *
23
+ * //Initialized slice
24
+ * let todos = [new Todo(false, "You complete me!"),
25
+ * new Todo(true, "You completed me!")];
26
+ * new Slice<Todo>(Todo.COMPLETE, todo=>!todo.complete, todos);
27
+ * ```
28
28
  */
29
29
  constructor(label: string, predicate: Predicate<E>, eStore: EStore<E>);
30
30
  /**
@@ -1,6 +1,6 @@
1
1
  import { ActionTypes } from "./ActionTypes";
2
2
  /**
3
- * Delta update interface models
3
+ * The Delta update interface models
4
4
  * the type of the update and the entities
5
5
  * associated with the update.
6
6
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireflysemantics/slice",
3
- "version": "17.0.14",
3
+ "version": "17.0.17",
4
4
  "peerDependencies": {
5
5
  "nanoid": "^5.0.4",
6
6
  "@types/nanoid": "*",