@webkrafters/eagleeye 1.0.0-beta.1 → 1.0.0-beta.2
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 +24 -24
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -7
- package/dist/main/index.d.ts +1 -1
- package/dist/main/index.js +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,36 +78,36 @@ const state = store.getState( Array<string> );
|
|
|
78
78
|
const unsubscribeFn = store.subscribe( eventType, listener );
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
###
|
|
82
|
-
A context stream allows
|
|
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
83
|
```tsx
|
|
84
84
|
const useStream = context.stream;
|
|
85
85
|
// joining the stream twice
|
|
86
86
|
// for more on selectorMap - https://eagleeye.js.org/concepts/selector-map/
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
// check whether a
|
|
90
|
-
if(
|
|
91
|
-
// access the current data value monitored by this
|
|
92
|
-
console.log( 'data',
|
|
93
|
-
// access the
|
|
94
|
-
console.log( 'life cycle',
|
|
95
|
-
// check if the
|
|
96
|
-
if(
|
|
97
|
-
// change a
|
|
98
|
-
|
|
99
|
-
// add listener to a
|
|
100
|
-
|
|
101
|
-
// be notified of a
|
|
102
|
-
|
|
103
|
-
// remove listener from a
|
|
104
|
-
|
|
87
|
+
const channel1 = useStream(SelectorMap?);
|
|
88
|
+
const channel2 = useStream(SelectorMap?);
|
|
89
|
+
// check whether a channel still defunct or still active
|
|
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
105
|
// https://eagleeye.js.org/concepts/store/resetstate/
|
|
106
|
-
|
|
106
|
+
channel1.resetState( Array<string>? ); // changes are context-wide
|
|
107
107
|
// https://eagleeye.js.org/concepts/store/setstate/
|
|
108
|
-
|
|
109
|
-
// exit
|
|
110
|
-
|
|
108
|
+
channel1.setState( Changes<T> ); // changes are context-wide
|
|
109
|
+
// exit channel from stream
|
|
110
|
+
channel1.endStream();
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
### Accessing underlying cache.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Changes as BaseChanges, Immutable as AutoImmutable, Value } from '@webkrafters/auto-immutable';
|
|
2
2
|
import { FULL_STATE_SELECTOR } from './constants';
|
|
3
|
-
import { createEagleEye,
|
|
3
|
+
import { createEagleEye, Channel } from './main';
|
|
4
4
|
export type { BaseType, ClearCommand, KeyType, MoveCommand, PushCommand, ReplaceCommand, SetCommand, SpliceCommand, TagCommand, TagType, UpdateStats, UpdatePayload, UpdatePayloadArray } from '@webkrafters/auto-immutable';
|
|
5
5
|
export type State = Value;
|
|
6
6
|
export type ShutdownMonitor = (reason: ShutdownReason) => void;
|
|
@@ -90,11 +90,11 @@ export interface StoreInternal<T extends State = State> extends StoreRef<T> {
|
|
|
90
90
|
closed: boolean;
|
|
91
91
|
}
|
|
92
92
|
export interface BaseStream<T extends State = State> {
|
|
93
|
-
<S extends SelectorMap>(selectorMap?: S):
|
|
93
|
+
<S extends SelectorMap>(selectorMap?: S): Channel<T, S>;
|
|
94
94
|
}
|
|
95
95
|
export interface Stream<T extends State = State> extends BaseStream<T> {
|
|
96
96
|
<S extends SelectorMap>(selectorMap?: S): Store<T, S>;
|
|
97
97
|
}
|
|
98
98
|
export { CLEAR_TAG, DELETE_TAG, FULL_STATE_SELECTOR, MOVE_TAG, NULL_SELECTOR, PUSH_TAG, REPLACE_TAG, SET_TAG, SPLICE_TAG, Tag, } from './constants';
|
|
99
|
-
export { createEagleEye, EagleEyeContext
|
|
99
|
+
export { Channel, createEagleEye, EagleEyeContext } from './main';
|
|
100
100
|
export default createEagleEye;
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.EagleEyeContext = exports.createEagleEye = exports.Channel = exports.Tag = exports.SPLICE_TAG = exports.SET_TAG = exports.REPLACE_TAG = exports.PUSH_TAG = exports.NULL_SELECTOR = exports.MOVE_TAG = exports.FULL_STATE_SELECTOR = exports.DELETE_TAG = exports.CLEAR_TAG = exports.ShutdownReason = exports.Phase = void 0;
|
|
7
7
|
var main_1 = require("./main");
|
|
8
8
|
;
|
|
9
9
|
;
|
|
@@ -87,22 +87,22 @@ Object.defineProperty(exports, "Tag", {
|
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
89
|
var main_2 = require("./main");
|
|
90
|
-
Object.defineProperty(exports, "
|
|
90
|
+
Object.defineProperty(exports, "Channel", {
|
|
91
91
|
enumerable: true,
|
|
92
92
|
get: function get() {
|
|
93
|
-
return main_2.
|
|
93
|
+
return main_2.Channel;
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
|
-
Object.defineProperty(exports, "
|
|
96
|
+
Object.defineProperty(exports, "createEagleEye", {
|
|
97
97
|
enumerable: true,
|
|
98
98
|
get: function get() {
|
|
99
|
-
return main_2.
|
|
99
|
+
return main_2.createEagleEye;
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
|
-
Object.defineProperty(exports, "
|
|
102
|
+
Object.defineProperty(exports, "EagleEyeContext", {
|
|
103
103
|
enumerable: true,
|
|
104
104
|
get: function get() {
|
|
105
|
-
return main_2.
|
|
105
|
+
return main_2.EagleEyeContext;
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
exports["default"] = main_1.createEagleEye;
|
package/dist/main/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const deps: {
|
|
|
6
6
|
createStorageKey: () => string;
|
|
7
7
|
};
|
|
8
8
|
export declare const ACCESS_SYM: unique symbol;
|
|
9
|
-
export declare class
|
|
9
|
+
export declare class Channel<T extends State = State, S extends SelectorMap = SelectorMap> implements Store<T, S> {
|
|
10
10
|
private _context;
|
|
11
11
|
private _internalStore;
|
|
12
12
|
private _data;
|
package/dist/main/index.js
CHANGED
|
@@ -118,7 +118,7 @@ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
|
118
118
|
Object.defineProperty(exports, "__esModule", {
|
|
119
119
|
value: true
|
|
120
120
|
});
|
|
121
|
-
exports.EagleEyeContext = exports.
|
|
121
|
+
exports.EagleEyeContext = exports.Channel = exports.ACCESS_SYM = exports.deps = void 0;
|
|
122
122
|
exports.createEagleEye = createEagleEye;
|
|
123
123
|
exports.mkReadonly = mkReadonly;
|
|
124
124
|
var lodash_isboolean_1 = __importDefault(require("lodash.isboolean"));
|
|
@@ -169,7 +169,7 @@ var Event = /*#__PURE__*/function () {
|
|
|
169
169
|
}
|
|
170
170
|
}]);
|
|
171
171
|
}();
|
|
172
|
-
var
|
|
172
|
+
var Channel = function () {
|
|
173
173
|
var _a;
|
|
174
174
|
var _instanceExtraInitializers = [];
|
|
175
175
|
var _set_selectorMap_decorators;
|
|
@@ -181,9 +181,9 @@ var Streamer = function () {
|
|
|
181
181
|
var _subscribe_decorators;
|
|
182
182
|
var _unsubscribe_decorators;
|
|
183
183
|
return _a = /*#__PURE__*/function () {
|
|
184
|
-
function
|
|
184
|
+
function Channel(context, selectorMap) {
|
|
185
185
|
var _this = this;
|
|
186
|
-
_classCallCheck(this,
|
|
186
|
+
_classCallCheck(this, Channel);
|
|
187
187
|
this._context = (__runInitializers(this, _instanceExtraInitializers), null);
|
|
188
188
|
this._internalStore = null;
|
|
189
189
|
this._data = {};
|
|
@@ -243,7 +243,7 @@ var Streamer = function () {
|
|
|
243
243
|
this._integrateSelectors(selectorMap);
|
|
244
244
|
this._phase = __1.Phase.OPENED;
|
|
245
245
|
}
|
|
246
|
-
return _createClass(
|
|
246
|
+
return _createClass(Channel, [{
|
|
247
247
|
key: "closed",
|
|
248
248
|
get: function get() {
|
|
249
249
|
return !this._internalStore || this._internalStore.closed;
|
|
@@ -517,7 +517,7 @@ var Streamer = function () {
|
|
|
517
517
|
});
|
|
518
518
|
}(), _a;
|
|
519
519
|
}();
|
|
520
|
-
exports.
|
|
520
|
+
exports.Channel = Channel;
|
|
521
521
|
var EagleEyeContext = function () {
|
|
522
522
|
var _a;
|
|
523
523
|
var _instanceExtraInitializers = [];
|
|
@@ -546,7 +546,7 @@ var EagleEyeContext = function () {
|
|
|
546
546
|
};
|
|
547
547
|
this.storageKey = null;
|
|
548
548
|
this._stream = function (selectorMap) {
|
|
549
|
-
return new
|
|
549
|
+
return new Channel(_this3, selectorMap);
|
|
550
550
|
};
|
|
551
551
|
if (!(value instanceof auto_immutable_1["default"])) {
|
|
552
552
|
this.inchoateValue = value;
|
package/package.json
CHANGED