Skip to content

Commit

Permalink
fix: rename multicast iterable to multicaster
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Oct 31, 2020
1 parent bcc84a1 commit dd7156b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion packages/notifier/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './notifier';
export * from './multicastIteratable';
export * from './multicaster';
export * from './asyncIterableAdaptor';
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import './types';
/**
* @template T
* @param {MulticastInternals} startP
* @returns {MulticastIterable<T>}
* @returns {Multicaster<T>}
*/
const makeMulticastIterable = startP => {
const makeMulticaster = startP => {
return harden({
// eslint-disable-next-line no-use-before-define
[Symbol.asyncIterator]: () => makeMulticastIterator(startP),
Expand All @@ -22,8 +22,8 @@ const makeMulticastIterable = startP => {
getSharableInternals: () => startP,
});
};
harden(makeMulticastIterable);
export { makeMulticastIterable };
harden(makeMulticaster);
export { makeMulticaster };

/**
* @template T
Expand All @@ -34,7 +34,7 @@ const makeMulticastIterator = tailP => {
// To understand the implementation, start with
// https://web.archive.org/web/20160404122250/http://wiki.ecmascript.org/doku.php?id=strawman:concurrency#infinite_queue
return harden({
snapshot: () => makeMulticastIterable(tailP),
snapshot: () => makeMulticaster(tailP),
[Symbol.asyncIterator]: () => makeMulticastIterator(tailP),
next: () => {
const resultP = E.G(tailP).head;
Expand All @@ -45,15 +45,15 @@ const makeMulticastIterator = tailP => {
};

/**
* `makeMulticastIterableKit()` makes an entanged `{updater, multicastIterable}`
* `makeMulticasterKit()` makes an entanged `{updater, multicaster}`
* pair which purposely resembles `makeNotifierKit` making an entangled
* `{updater, notifier}` pair.
*
* Both `updater`s have the same API with the same meaning --- to push a
* sequence of non-final values, terminated with either a final successful
* completion value or failure reason. In both cases, the other side of the
* pair---the `multicastIterable` or `notifier`---implements the JavaScript
* standard async iterator API, and so may be read using a JavaScript
* pair---the `multicaster` or `notifier`---implements the JavaScript
* standard async iteratable API, and so may be read using a JavaScript
* `for-await-of` loop.
*
* In both cases, all the non-final values read will be non-final values pushed
Expand All @@ -67,29 +67,29 @@ const makeMulticastIterator = tailP => {
* `multicastIterator` returned here provides lossless access to the entire
* stream of non-final values. (Both losslessly report termination.)
*
* Of the `{updater, multicastIterable}` pair returned by `makeIterableKit()`,
* this initial `multicastIterable` represents the stream starting with the
* first update to the `updater`. Each multicast iterable makes any number of
* Of the `{updater, multicaster}` pair returned by `makeMulticasterKit()`,
* this initial `multicaster` represents the stream starting with the
* first update to the `updater`. Each multicaster makes any number of
* multicast iterators, each of which advance independently starting at that
* iterable's starting point. These multicast iterators also have a
* `snapshot()` method which will create a new multicast iterable capturing the
* `snapshot()` method which will create a new multicaster capturing the
* iterator's current position as the new iterable's starting point.
*
* As is conventional, the multicast iterator is also an multicast iterable that
* produces an multicast iterator. In this case, it produces a new multicast
* iterator that advances independently starting from the current position.
* As is conventional, the iterator is itself also an iterable.
* Here this means the multicast iterator is also a multicaster
* (a kind of iterable) that produces a multicast iterator. In this case,
* it produces a new multicast iterator that advances independently starting
* from the current position.
*
* The internal representation ensure that elements that are no longer
* The internal representation ensures that elements that are no longer
* observable are unreachable and can be gc'ed.
*
* @template T
* @returns {MulticastIteratorRecord<T>}
* @returns {MulticasterRecord<T>}
*/
const makeMulticastIteratableKit = () => {
const makeMulticasterKit = () => {
let rear;
const multicastIterable = makeMulticastIterable(
new HandledPromise(r => (rear = r)),
);
const multicaster = makeMulticaster(new HandledPromise(r => (rear = r)));

const updater = harden({
updateState: value => {
Expand Down Expand Up @@ -118,7 +118,7 @@ const makeMulticastIteratableKit = () => {
rear = undefined;
},
});
return harden({ updater, multicastIterable });
return harden({ updater, multicaster });
};
harden(makeMulticastIteratableKit);
export { makeMulticastIteratableKit };
harden(makeMulticasterKit);
export { makeMulticasterKit };
10 changes: 5 additions & 5 deletions packages/notifier/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

/**
* @template T
* @typedef {AsyncIterable<T>} MulticastIterable<T> A form of AsyncIterable
* @typedef {AsyncIterable<T>} Multicaster<T> A form of AsyncIterable
* supporting distributed and multicast usage.
*
* TODO How do I declare a symbol-named property in the JSDoc type syntax?
Expand All @@ -89,7 +89,7 @@
*
* @property {() => MulticastInternals} getSharableInternals Used to replicate
* the multicast values at other sites. To manually create a local
* representative of a MulticastIterable, do
* representative of a Multicaster, do
* ```js
* localIterable = makeAsyncIterable(E(remoteIterable).getSharableInternals());
* ```
Expand All @@ -102,13 +102,13 @@
* @typedef {AsyncIterator<T> & AsyncIterable<T>} MulticastIterator<T>
* an AsyncIterator supporting distributed and multicast usage.
*
* @property {() => MulticastIterable<T>} snapshot
* @property {() => Multicaster<T>} snapshot
*
*/

/**
* @template T
* @typedef {Object} MulticastIteratorRecord<T>
* @typedef {Object} MulticasterRecord<T>
* @property {Updater<T>} updater
* @property {MulticastIterable<T>} multicastIterable
* @property {Multicaster<T>} multicaster
*/

0 comments on commit dd7156b

Please sign in to comment.