You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ This project demonstrate **how reactive programming is way more simple to implem
45
45
46
46
### The main idea
47
47
48
-
The share state is just a tree of objects hosted in a singleton called a store. Any modification on this tree will fire an event inside an event bus. We are going to build this event bus using an Rx [Observable](https://RxJS-dev.firebaseapp.com/guide/observable). You can subscribe to it and unsubscribe from it at any point in time.
48
+
The shared state is just a tree of objects hosted in a singleton called a **store**. Any modification on this tree will fire an event inside an event bus. We are going to build this event bus using an Rx [Observable](https://RxJS-dev.firebaseapp.com/guide/observable). You can subscribe to it and unsubscribe from it at any point in time.
49
49
50
50
The observable is like a stream of events. Each event is just a string saying "the property A.B.C.D in the shared state have changed".
51
51
@@ -62,7 +62,7 @@ The beauty of Rx is that you can filter the stream of events before subscribing
62
62
observable.pipe(filter(event=>...select what you want...)).subscribe(subscriberCallBack)
63
63
```
64
64
65
-
In the class `GlobalStore` we used this technique in the method `subscribe`.
65
+
In the ES6 class `GlobalStore` we use this technique in the method `subscribe`.
66
66
67
67
-`MyAppStore.subscribe("a.b.c",callback)`: react only on this specific node
68
68
-`MyAppStore.subscribe("a.*",callback)`: react to any change on node 'a' and below
@@ -98,14 +98,14 @@ Example:
98
98
99
99
### Protect the shared state
100
100
101
-
It would be very dangerous to give a direct reference to the share state to the consumer. Remember we want to keep unidirectional data flow. Here some solutions to this problem:
101
+
It would be very dangerous to give a direct reference to the shared state to the consumer. Remember we want to keep unidirectional data flow. Here some solutions to this problem:
102
102
103
103
- We can clone before delivering the value
104
104
- We can use a library that promote immutable data structures like [immutable.js](https://immutable-js.github.io/immutable-js/)
105
105
106
106
To keep it simple, we opted to clone the value, even it is slow.
107
107
108
-
## A little of OOP for better encapsulation
108
+
## A little bit of OOP for better encapsulation
109
109
110
110
The ES6 class `GlobalStore` provides the basics of a shared state with an event bus powered by RxJS.
0 commit comments