@fireflysemantics/slice 17.0.11 → 17.0.13
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/README.md +39 -3
- package/package.json +1 -1
package/README.md
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
## TOC
|
6
6
|
|
7
7
|
- [Overview](#overview)
|
8
|
+
- [Why Slice](#why-slice)
|
8
9
|
- [Install](#install)
|
9
10
|
- [Object Store Core Use Cases](#object-store-core-use-cases)
|
10
11
|
- [Entity Store Core Use Cases](#entity-store-core-use-cases)
|
@@ -18,8 +19,7 @@ Lightweight Javascript Reactive State Management for Angular Applications.
|
|
18
19
|
The API is designed to be as minimal as possible and should deliver the same features as other comparable frameworks with about 1/3 the lines of code.
|
19
20
|
|
20
21
|
It offers two types of reactive data stores:
|
21
|
-
- Entity stores (EStore<E>) for structured entity like data (Customer, Product, User, ...)
|
22
|
-
- Entity stores can be "Live filtered" by adding slices. For example separating Todo entities into complete and incomplete compartments. Slices are also obserable.
|
22
|
+
- Entity stores (EStore<E>) for structured entity like data (Customer, Product, User, ...). Entity stores can be "Live filtered" by adding slices. For example separating Todo entities into complete and incomplete compartments. Slices are also obserable.
|
23
23
|
- Object store (Key value store) for unstructured data
|
24
24
|
|
25
25
|
Even though Angular is used for prototype applications, it should work well in general for:
|
@@ -30,6 +30,42 @@ Even though Angular is used for prototype applications, it should work well in g
|
|
30
30
|
|
31
31
|
If you like the [@fireflysemantics/slice API](https://fireflysemantics.github.io/slice/doc/) please star our [Github Repository](https://github.com/fireflysemantics/slice).
|
32
32
|
|
33
|
+
# Why Slice
|
34
|
+
|
35
|
+
We built Slice to make sharing state between Angular components, services, and other directives simple and in the process we targeted common use cases that should be handled by a state manager, such as updating a shopping cart count, emitting a search query, tracking active state, etc.
|
36
|
+
|
37
|
+
For performing state CRUD operations Slice uses a REST like API, which should be a familiar paradigm for most developers.
|
38
|
+
|
39
|
+
For example a `Todo` entity store tracking todo entities can create, read, update, and delete `Todo` entities as follows (This is just a tiny example of all the capabilities Slice has).
|
40
|
+
|
41
|
+
```
|
42
|
+
let store: EStore<Todo> = new EStore<Todo>();
|
43
|
+
//============================================
|
44
|
+
// Post (Create) a Todo instance in the store
|
45
|
+
//============================================
|
46
|
+
store.post(todo);
|
47
|
+
//============================================
|
48
|
+
// Snapshot of all the Todo entities in the
|
49
|
+
// store
|
50
|
+
//============================================
|
51
|
+
let snapshot: Todo[] = store.allSnapshot();
|
52
|
+
//============================================
|
53
|
+
// Observe the array of Todo instances in the
|
54
|
+
// store
|
55
|
+
//============================================
|
56
|
+
store.obs.subscribe((todos: Todo[]) => {
|
57
|
+
console.log(`The store is initialized with these Todo entities ${todos}`);
|
58
|
+
});
|
59
|
+
//============================================
|
60
|
+
// Delete a Todo instance in the store
|
61
|
+
//============================================
|
62
|
+
todo.complete = false;
|
63
|
+
store.put(todo);
|
64
|
+
//============================================
|
65
|
+
// Delete a Todo instance in the store
|
66
|
+
//============================================
|
67
|
+
store.delete(todo);
|
68
|
+
```
|
33
69
|
|
34
70
|
# Install
|
35
71
|
|
@@ -452,7 +488,7 @@ store.isEmpty().subscribe((empty) => {
|
|
452
488
|
## Features
|
453
489
|
|
454
490
|
- Live Stackblitz demoes
|
455
|
-
- [Typedoc with inlined examples](https://fireflysemantics.github.io/slice/
|
491
|
+
- [Typedoc with inlined examples](https://fireflysemantics.github.io/slice/typedoc/)
|
456
492
|
- [Well documented test cases run with Jest - Each file has a corresponding `.spec` file](https://github.com/fireflysemantics/slice/tree/master/src)
|
457
493
|
- Stream both Entity and Object Stores for UI Updates via RxJS
|
458
494
|
- Define entities using Typescript classes, interfaces, or types
|