@webkrafters/eagleeye 1.0.0-beta.4 → 1.0.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.
- package/README.md +7 -118
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
<a href="https://coveralls.io/github/webKrafters/eagleeye.js">
|
|
12
12
|
<img alt="coverage" src="https://img.shields.io/coveralls/github/webKrafters/eagleeye.js">
|
|
13
13
|
</a>
|
|
14
|
-
<img alt="NPM" src="https://img.shields.io/npm/l/@webkrafters/eagleeye
|
|
14
|
+
<img alt="NPM" src="https://img.shields.io/npm/l/@webkrafters/eagleeye">
|
|
15
15
|
<img alt="Maintenance" src="https://img.shields.io/maintenance/yes/2032">
|
|
16
|
-
<img alt="build size" src="https://img.shields.io/bundlephobia/minzip/@webkrafters/eagleeye
|
|
17
|
-
<a href="https://www.npmjs.com/package/@webKrafters/eagleeye
|
|
18
|
-
<img alt="Downloads" src="https://img.shields.io/npm/dt/@webkrafters/eagleeye.
|
|
16
|
+
<img alt="build size" src="https://img.shields.io/bundlephobia/minzip/@webkrafters/eagleeye?label=bundle%20size">
|
|
17
|
+
<a href="https://www.npmjs.com/package/@webKrafters/eagleeye">
|
|
18
|
+
<img alt="Downloads" src="https://img.shields.io/npm/dt/@webkrafters/eagleeye.svg">
|
|
19
19
|
</a>
|
|
20
20
|
<img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/webKrafters/eagleeye.js">
|
|
21
21
|
</p>
|
|
@@ -28,126 +28,15 @@
|
|
|
28
28
|
|
|
29
29
|
<br />
|
|
30
30
|
<p><b>Name:</b> Eagle Eye.</p>
|
|
31
|
-
|
|
32
|
-
<b>Install:</b>
|
|
33
|
-
npm install --save @webkrafters/eagleeye
|
|
34
|
-
</p>
|
|
31
|
+
|
|
35
32
|
<br />
|
|
36
33
|
|
|
37
34
|
## Usage:
|
|
38
|
-
### Create (the FP way).
|
|
39
|
-
```tsx
|
|
40
|
-
import { createEagleEye } from '@webkrafters/eagleeye';
|
|
41
|
-
const context = createEagleEye({
|
|
42
|
-
prehooks?: Prehooks<T>,
|
|
43
|
-
storage?: Storage<T>,
|
|
44
|
-
value?: T|AutoImmutable<T>
|
|
45
|
-
});
|
|
46
|
-
```
|
|
47
|
-
### Create (the OOP way).
|
|
48
|
-
```tsx
|
|
49
|
-
import { EagleEyeContext } from '@webkrafters/eagleeye';
|
|
50
|
-
const context = new EagleEyeContext<T>(
|
|
51
|
-
T?|AutoImmutable<T>?,
|
|
52
|
-
Prehooks<T>?,
|
|
53
|
-
Storage<T>?
|
|
54
|
-
);
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### Releasing context resources.
|
|
58
|
-
```tsx
|
|
59
|
-
context.dispose();
|
|
60
|
-
```
|
|
61
|
-
Deactivates this context by:
|
|
62
|
-
<ol>
|
|
63
|
-
<li>unsubscribing all observers to it</li>
|
|
64
|
-
<li>severing connections to data stores</li>
|
|
65
|
-
<li>unsetting all resources</li>
|
|
66
|
-
</ol>
|
|
67
|
-
|
|
68
|
-
### Accessing external store reference.
|
|
69
|
-
```tsx
|
|
70
|
-
const store = context.store;
|
|
71
|
-
// https://eagleeye.js.org/concepts/store/resetstate/
|
|
72
|
-
store.resetState( Array<string>? );
|
|
73
|
-
// https://eagleeye.js.org/concepts/store/setstate/
|
|
74
|
-
store.setState( Changes<T> );
|
|
75
|
-
// https://eagleeye.js.org/concepts/store/getstate/
|
|
76
|
-
const state = store.getState( Array<string> );
|
|
77
|
-
// https://eagleeye.js.org/concepts/store/subscribe/
|
|
78
|
-
const unsubscribeFn = store.subscribe( eventType, listener );
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Joining the context stream.
|
|
82
|
-
A context stream allows a client to set up a dedicated channel through which it receives automatic updates whenever its selected slices of state change. It can also update the context through this channel.
|
|
83
|
-
```tsx
|
|
84
|
-
const useStream = context.stream;
|
|
85
|
-
// joining the stream twice
|
|
86
|
-
// for more on selectorMap - https://eagleeye.js.org/concepts/selector-map/
|
|
87
|
-
const channel1 = useStream(SelectorMap?);
|
|
88
|
-
const channel2 = useStream(SelectorMap?);
|
|
89
|
-
// check whether a channel is still active or defunt
|
|
90
|
-
if( channel1.closed ) { ... };
|
|
91
|
-
// access the current data value monitored by this channel
|
|
92
|
-
console.log( 'data', channel1.data );
|
|
93
|
-
// access the channel current lifecycle
|
|
94
|
-
console.log( 'life cycle', channel1.phase );
|
|
95
|
-
// check if the channel is streaming
|
|
96
|
-
if( channel1.streaming ) { ... };
|
|
97
|
-
// change a channel's selector map
|
|
98
|
-
channel1.seletorMap = SelectorMap<T>?;
|
|
99
|
-
// add listener to a channel to react to live updates to selected data.
|
|
100
|
-
channel1.addListener( 'data-changed', listener );
|
|
101
|
-
// be notified of a channel's exit from stream.
|
|
102
|
-
channel1.addListener( 'stream-ending', listener );
|
|
103
|
-
// remove listener from a channel activities
|
|
104
|
-
channel1.removeListener( 'data-changed'|'stream-ending', listener );
|
|
105
|
-
// https://eagleeye.js.org/concepts/store/resetstate/
|
|
106
|
-
channel1.resetState( Array<string>? ); // changes are context-wide
|
|
107
|
-
// https://eagleeye.js.org/concepts/store/setstate/
|
|
108
|
-
channel1.setState( Changes<T> ); // changes are context-wide
|
|
109
|
-
// exit channel from stream
|
|
110
|
-
channel1.endStream();
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Accessing underlying cache.
|
|
114
|
-
```tsx
|
|
115
|
-
const cache = context.cache;
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Accessing `close` status.
|
|
119
|
-
```tsx
|
|
120
|
-
const closed = context.closed;
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### Accessing current state update `prehooks`.
|
|
124
|
-
```tsx
|
|
125
|
-
const prehooks = context.prehooks;
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### Updating state update `prehooks`.
|
|
129
|
-
```tsx
|
|
130
|
-
context.prehooks = Prehooks<T>?;
|
|
131
|
-
```
|
|
132
35
|
|
|
133
|
-
|
|
134
|
-
```tsx
|
|
135
|
-
const storage = context.storage;
|
|
136
|
-
```
|
|
36
|
+
Please consult the [Getting Started](https://eagleeye.js.org/gettiing-started) page to quick information regarding usage.
|
|
137
37
|
|
|
138
|
-
|
|
139
|
-
```tsx
|
|
140
|
-
context.storage = storage<T>?;
|
|
141
|
-
```
|
|
38
|
+
There are also framework specific Eagle-Eye installations such as the [React Observable Context](https://www.npmjs.com/package/@webkrafters/react-observable-context).
|
|
142
39
|
|
|
143
|
-
## Notable Mentions:
|
|
144
|
-
<ul>
|
|
145
|
-
<li>Facilitates sharing of underlying immutable data structure among multiple applications</li>
|
|
146
|
-
<li>Update-friendly Auto-immutable bearing context. See <a href="https://eagleeye.js.org/concepts/store/setstate"><code>store.setState</code></a>.</li>
|
|
147
|
-
<li> Recognizes <b>negative array indexing</b>. Please see <a href="https://eagleeye.js.org/concepts/property-path">Property Path</a> and <code>store.setState</code> <a href="https://eagleeye.js.org/concepts/store/setstate#indexing">Indexing</a>.</li>
|
|
148
|
-
<li> Only automatically notifying subscribing or stream (<a href="https://eagleeye.js.org/concepts/client">clients</a>) on context state changes.</li>
|
|
149
|
-
<li> Subscribers decide which exact context state properties' changes to monitor.</li>
|
|
150
|
-
</ul>
|
|
151
40
|
|
|
152
41
|
## Please see more documentation here:
|
|
153
42
|
**[eagleeye.js.org](https://eagleeye.js.org)**
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"alias": "Eagle
|
|
2
|
+
"alias": "Eagle Eye JS",
|
|
3
3
|
"author": "Stephen Isienyi <stephen.isienyi@webkrafters.tech>",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/webKrafters/eagleeye.js/issues"
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"state management",
|
|
70
70
|
"state manager"
|
|
71
71
|
],
|
|
72
|
-
"license": "
|
|
72
|
+
"license": "GPL-3.0-only",
|
|
73
73
|
"main": "dist/index.js",
|
|
74
74
|
"name": "@webkrafters/eagleeye",
|
|
75
75
|
"peerDependencies": {
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"test:watch": "eslint --fix && jest --updateSnapshot --watchAll"
|
|
98
98
|
},
|
|
99
99
|
"types": "dist/index.d.ts",
|
|
100
|
-
"version": "1.0.0
|
|
100
|
+
"version": "1.0.0",
|
|
101
101
|
"dependencies": {
|
|
102
102
|
"@webkrafters/auto-immutable": "^2.0.5"
|
|
103
103
|
}
|