Skip to content

Commit 49a6a8e

Browse files
authored
fix(notifier): add Far/Data to notifier (#2565)
* fix(notifier): extract many fixes from Kate's PR This pulls in a subset of the changes from #2545 , which seemed easier than iterating on that branch or applying more fixes on top. Thanks @katelynsills for the cleanup! * fix(notifier): add Far to subscriber refs #2018
1 parent 4c07722 commit 49a6a8e

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

packages/notifier/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
"dependencies": {
3838
"@agoric/assert": "^0.2.2",
3939
"@agoric/eventual-send": "^0.13.2",
40+
"@agoric/marshal": "^0.3.2",
4041
"@agoric/promise-kit": "^0.2.2"
4142
},
4243
"devDependencies": {
4344
"@agoric/install-ses": "^0.5.2",
44-
"@agoric/marshal": "^0.3.2",
4545
"ava": "^3.12.1",
4646
"esm": "^3.2.25",
4747
"nyc": "^15.1.0"

packages/notifier/src/notifier.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import { makePromiseKit } from '@agoric/promise-kit';
66
import { assert } from '@agoric/assert';
7+
import { Far } from '@agoric/marshal';
78
import {
89
makeAsyncIterableFromNotifier,
910
observeIteration,
@@ -68,7 +69,7 @@ export const makeNotifierKit = (...args) => {
6869
},
6970
});
7071

71-
const notifier = harden({
72+
const notifier = Far('notifier', {
7273
...makeNotifier(baseNotifier),
7374
// TODO stop exposing baseNotifier methods directly
7475
...baseNotifier,

packages/notifier/src/subscriber.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/// <reference types="ses"/>
44

55
import { HandledPromise, E } from '@agoric/eventual-send';
6+
import { Far } from '@agoric/marshal';
67
import { makePromiseKit } from '@agoric/promise-kit';
78

89
import './types';
@@ -13,7 +14,7 @@ import './types';
1314
* @returns {Subscription<T>}
1415
*/
1516
const makeSubscription = startP => {
16-
return harden({
17+
return Far('Subscription', {
1718
// eslint-disable-next-line no-use-before-define
1819
[Symbol.asyncIterator]: () => makeSubscriptionIterator(startP),
1920

@@ -39,7 +40,7 @@ export { makeSubscription };
3940
const makeSubscriptionIterator = tailP => {
4041
// To understand the implementation, start with
4142
// https://web.archive.org/web/20160404122250/http://wiki.ecmascript.org/doku.php?id=strawman:concurrency#infinite_queue
42-
return harden({
43+
return Far('SubscriptionIterator', {
4344
subscribe: () => makeSubscription(tailP),
4445
[Symbol.asyncIterator]: () => makeSubscriptionIterator(tailP),
4546
next: () => {
@@ -61,7 +62,7 @@ const makeSubscriptionKit = () => {
6162
let rear;
6263
const subscription = makeSubscription(new HandledPromise(r => (rear = r)));
6364

64-
const publication = harden({
65+
const publication = Far('publication', {
6566
updateState: value => {
6667
if (rear === undefined) {
6768
throw new Error('Cannot update state after termination.');

0 commit comments

Comments
 (0)