@webkrafters/eagleeye 1.0.0-beta.1 → 1.0.0-beta.3

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 CHANGED
@@ -78,36 +78,36 @@ const state = store.getState( Array<string> );
78
78
  const unsubscribeFn = store.subscribe( eventType, listener );
79
79
  ```
80
80
 
81
- ### Connecting to context stream.
82
- A context stream allows for a client to set up automatic update to to be automatically pushed to it whenever its slice of state changes.
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 streamer1 = useStream(SelectorMap?);
88
- const streamer2 = useStream(SelectorMap?);
89
- // check whether a streamer still defunct or still active
90
- if( streamer1.closed ) { ... };
91
- // access the current data value monitored by this streamer
92
- console.log( 'data', streamer1.data );
93
- // access the streamer current lifecycle
94
- console.log( 'life cycle', streamer1.phase );
95
- // check if the streamer is streaming
96
- if( streamer1.streaming ) { ... };
97
- // change a streamer's selector map
98
- streamer1.seletorMap = SelectorMap<T>?;
99
- // add listener to a streamer to react to live updates to selected data.
100
- streamer1.addListener( 'data-changed', listener );
101
- // be notified of a streamer's exist from streaming.
102
- streamer1.addListener( 'stream-ending', listener );
103
- // remove listener from a streamer activities
104
- streamer1.removeListener( 'data-changed'|'stream-ending', listener );
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
105
  // https://eagleeye.js.org/concepts/store/resetstate/
106
- streamer1.resetState( Array<string>? ); // changes are context-wide
106
+ channel1.resetState( Array<string>? ); // changes are context-wide
107
107
  // https://eagleeye.js.org/concepts/store/setstate/
108
- streamer1.setState( Changes<T> ); // changes are context-wide
109
- // exit streamer from streaming
110
- streamer1.endStream();
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,7 +1,7 @@
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, Streamer } from './main';
4
- export type { BaseType, ClearCommand, KeyType, MoveCommand, PushCommand, ReplaceCommand, SetCommand, SpliceCommand, TagCommand, TagType, UpdateStats, UpdatePayload, UpdatePayloadArray } from '@webkrafters/auto-immutable';
3
+ import { createEagleEye, Channel } from './main';
4
+ export type { BaseType, ClearCommand, Immutable as AutoImmutable, 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;
7
7
  export type Listener = <T extends State>(changes: Changes<T>, changedPathsTokens: Readonly<Array<Array<string>>>, netChanges: Readonly<T>, mayHaveChangesAt: (pathTokens: Array<string>) => boolean) => 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): Streamer<T, 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, Streamer } from './main';
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.Streamer = exports.EagleEyeContext = exports.createEagleEye = 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;
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, "createEagleEye", {
90
+ Object.defineProperty(exports, "Channel", {
91
91
  enumerable: true,
92
92
  get: function get() {
93
- return main_2.createEagleEye;
93
+ return main_2.Channel;
94
94
  }
95
95
  });
96
- Object.defineProperty(exports, "EagleEyeContext", {
96
+ Object.defineProperty(exports, "createEagleEye", {
97
97
  enumerable: true,
98
98
  get: function get() {
99
- return main_2.EagleEyeContext;
99
+ return main_2.createEagleEye;
100
100
  }
101
101
  });
102
- Object.defineProperty(exports, "Streamer", {
102
+ Object.defineProperty(exports, "EagleEyeContext", {
103
103
  enumerable: true,
104
104
  get: function get() {
105
- return main_2.Streamer;
105
+ return main_2.EagleEyeContext;
106
106
  }
107
107
  });
108
108
  exports["default"] = main_1.createEagleEye;
@@ -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 Streamer<T extends State = State, S extends SelectorMap = SelectorMap> implements Store<T, S> {
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;
@@ -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.Streamer = exports.ACCESS_SYM = exports.deps = void 0;
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 Streamer = function () {
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 Streamer(context, selectorMap) {
184
+ function Channel(context, selectorMap) {
185
185
  var _this = this;
186
- _classCallCheck(this, Streamer);
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(Streamer, [{
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.Streamer = Streamer;
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 Streamer(_this3, selectorMap);
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
@@ -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-beta.1",
100
+ "version": "1.0.0-beta.3",
101
101
  "dependencies": {
102
102
  "@webkrafters/auto-immutable": "^2.0.5"
103
103
  }