@atlassian/clientside-extensions-base 2.4.1 → 2.5.0-84fa90d-kwd5ix2w
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/dist/cjs/DeferredSubject.js +1 -1
- package/dist/cjs/DeferredSubject.js.map +1 -1
- package/dist/cjs/ReplaySubject.js +1 -1
- package/dist/cjs/ReplaySubject.js.map +1 -1
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/DeferredSubject.js.map +1 -1
- package/dist/esm/ReplaySubject.js.map +1 -1
- package/dist/types/DeferredSubject.d.ts.map +1 -1
- package/dist/types/ReplaySubject.d.ts.map +1 -1
- package/lib/DeferredSubject.ts +2 -2
- package/lib/ReplaySubject.ts +2 -2
- package/package.json +3 -2
- package/dist/cjs/DeferredSubject.test.js +0 -95
- package/dist/cjs/DeferredSubject.test.js.map +0 -1
- package/dist/cjs/ReplaySubject.test.js +0 -45
- package/dist/cjs/ReplaySubject.test.js.map +0 -1
- package/dist/cjs/Subject.test.js +0 -56
- package/dist/cjs/Subject.test.js.map +0 -1
- package/dist/esm/DeferredSubject.test.js +0 -92
- package/dist/esm/DeferredSubject.test.js.map +0 -1
- package/dist/esm/ReplaySubject.test.js +0 -42
- package/dist/esm/ReplaySubject.test.js.map +0 -1
- package/dist/esm/Subject.test.js +0 -53
- package/dist/esm/Subject.test.js.map +0 -1
- package/dist/types/DeferredSubject.test.d.ts +0 -2
- package/dist/types/DeferredSubject.test.d.ts.map +0 -1
- package/dist/types/ReplaySubject.test.d.ts +0 -2
- package/dist/types/ReplaySubject.test.d.ts.map +0 -1
- package/dist/types/Subject.test.d.ts +0 -2
- package/dist/types/Subject.test.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const Subject_1 = tslib_1.__importDefault(require("./Subject"));
|
|
4
|
+
const Subject_1 = (0, tslib_1.__importDefault)(require("./Subject"));
|
|
5
5
|
/**
|
|
6
6
|
* Subject for a single location and its observers
|
|
7
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeferredSubject.js","sourceRoot":"","sources":["../../lib/DeferredSubject.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"DeferredSubject.js","sourceRoot":"","sources":["../../lib/DeferredSubject.ts"],"names":[],"mappings":";;;AACA,qEAAgC;AAIhC;;;;;GAKG;AACH,MAAqB,eAAmB,SAAQ,iBAAU;IAKtD,YAAoB,UAAkB,CAAC;QACnC,KAAK,EAAE,CAAC;QADQ,YAAO,GAAP,OAAO,CAAY;QAJ/B,gBAAW,GAAS,IAAI,CAAC;IAMjC,CAAC;IAED;;;OAGG;IACa,MAAM,CAAC,OAAU;QAC7B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAE3B,oEAAoE;QACpE,wEAAwE;QACxE,mGAAmG;QACnG,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,GAAG,EAAE;YAC/B,IAAI,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAES,UAAU;QAChB,YAAY,CAAC,IAAI,CAAC,WAAqB,CAAC,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC5B,CAAC;IAES,KAAK;QACX,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACM,SAAS,CAAC,QAAqB;QACpC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE9B,iGAAiG;QACjG,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC;QAChD,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI,aAAa,EAAE;YACjD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC9B;QAED,OAAO;YACH,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;SAChD,CAAC;IACN,CAAC;CACJ;AArDD,kCAqDC","sourcesContent":["import type { Observer, Subscription } from './Subject';\nimport Subject from './Subject';\n\nexport type Tick = null | number | NodeJS.Timer;\n\n/**\n * Subject for a single location and its observers\n *\n * Observers are callbacks provided by the different instances of a location that want to be notified\n * when a list of descriptors changed and is available to be rendered.\n */\nexport default class DeferredSubject<T> extends Subject<T> {\n private notifyTimer: Tick = null;\n\n private lastPayload!: T;\n\n constructor(private timeout: number = 0) {\n super();\n }\n\n /**\n * @Override\n * Notify all observers with a list of descriptors. Send the last value sent if no value is provided.\n */\n public override notify(payload: T) {\n this.clearTimer();\n this.lastPayload = payload;\n\n // The resources for a specific location will be loaded all at once.\n // We defer updating the observers until the last such update made it in\n // so we dont call observers overly often, which could result in a waste of expensive calculations.\n this.notifyTimer = setTimeout(() => {\n this.flush();\n }, this.timeout);\n }\n\n protected clearTimer() {\n clearTimeout(this.notifyTimer as number);\n this.notifyTimer = null;\n }\n\n protected flush() {\n this.clearTimer();\n this.observers.forEach((observer) => observer(this.lastPayload));\n }\n\n /**\n * @Override\n * Add an observer to the location subject. The observer will be notified each time there's a new list of\n * descriptors ready to be renderer.\n */\n override subscribe(observer: Observer<T>): Subscription {\n this.observers.push(observer);\n\n // no notify timer is running - otherwise just wait for the cycle to update the location observer\n const noNotifyTimer = this.notifyTimer === null;\n if (this.lastPayload !== undefined && noNotifyTimer) {\n observer(this.lastPayload);\n }\n\n return {\n unsubscribe: () => this.unsubscribe(observer),\n };\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const Subject_1 = tslib_1.__importDefault(require("./Subject"));
|
|
4
|
+
const Subject_1 = (0, tslib_1.__importDefault)(require("./Subject"));
|
|
5
5
|
/**
|
|
6
6
|
* Subject for a single location and its observers
|
|
7
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReplaySubject.js","sourceRoot":"","sources":["../../lib/ReplaySubject.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"ReplaySubject.js","sourceRoot":"","sources":["../../lib/ReplaySubject.ts"],"names":[],"mappings":";;;AACA,qEAAgC;AAEhC;;;;;GAKG;AACH,MAAqB,aAAiB,SAAQ,iBAAU;IAKpD,YAAY,aAAqB,EAAE;QAC/B,KAAK,EAAE,CAAC;QALJ,iBAAY,GAAQ,EAAE,CAAC;QAM3B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEO,UAAU,CAAC,OAAU;QACzB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChC,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE;YAC5C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACjE;IACL,CAAC;IAED;;;OAGG;IACa,MAAM,CAAC,OAAU;QAC7B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACzB,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACM,SAAS,CAAC,QAAqB;QACpC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAClC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,KAAK;QACD,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IACjC,CAAC;CACJ;AA1CD,gCA0CC","sourcesContent":["import type { Observer, Subscription } from './Subject';\nimport Subject from './Subject';\n\n/**\n * Subject for a single location and its observers\n *\n * Observers are callbacks provided by the different instances of a location that want to be notified\n * when a list of descriptors changed and is available to be rendered.\n */\nexport default class ReplaySubject<T> extends Subject<T> {\n private lastPayloads: T[] = [];\n\n private readonly replaySize: number;\n\n constructor(replaySize: number = 10) {\n super();\n this.replaySize = Math.abs(replaySize);\n }\n\n private addPayload(payload: T) {\n this.lastPayloads.push(payload);\n if (this.lastPayloads.length > this.replaySize) {\n this.lastPayloads = this.lastPayloads.slice(-this.replaySize);\n }\n }\n\n /**\n * @Override\n * Notify all observers with a list of descriptors. Send the last value sent if no value is provided.\n */\n public override notify(payload: T) {\n this.addPayload(payload);\n super.notify(payload);\n }\n\n /**\n * @Override\n * Add an observer to the location subject. The observer will be notified each time there's a new list of\n * descriptors ready to be renderer.\n */\n override subscribe(observer: Observer<T>): Subscription {\n this.lastPayloads.forEach((payload) => {\n observer(payload);\n });\n\n return super.subscribe(observer);\n }\n\n prune() {\n this.lastPayloads.length = 0;\n }\n}\n"]}
|
package/dist/cjs/index.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReplaySubject = exports.DeferredSubject = exports.Subject = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const Subject_1 = tslib_1.__importDefault(require("./Subject"));
|
|
5
|
+
const Subject_1 = (0, tslib_1.__importDefault)(require("./Subject"));
|
|
6
6
|
exports.Subject = Subject_1.default;
|
|
7
|
-
const DeferredSubject_1 = tslib_1.__importDefault(require("./DeferredSubject"));
|
|
7
|
+
const DeferredSubject_1 = (0, tslib_1.__importDefault)(require("./DeferredSubject"));
|
|
8
8
|
exports.DeferredSubject = DeferredSubject_1.default;
|
|
9
|
-
const ReplaySubject_1 = tslib_1.__importDefault(require("./ReplaySubject"));
|
|
9
|
+
const ReplaySubject_1 = (0, tslib_1.__importDefault)(require("./ReplaySubject"));
|
|
10
10
|
exports.ReplaySubject = ReplaySubject_1.default;
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAI/D,kBAJF,iBAAO,CAIE;AAHhB,qFAAgD;AAG9B,0BAHX,yBAAe,CAGW;AAFjC,iFAA4C;AAET,wBAF5B,uBAAa,CAE4B","sourcesContent":["import Subject, { Observer, Observable, Subscription } from './Subject';\nimport DeferredSubject from './DeferredSubject';\nimport ReplaySubject from './ReplaySubject';\n\nexport { Subject, DeferredSubject, ReplaySubject, Observable, Subscription, Observer };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeferredSubject.js","sourceRoot":"","sources":["../../lib/DeferredSubject.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,WAAW,CAAC;AAIhC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,eAAmB,SAAQ,OAAU;IAKtD,YAAoB,UAAkB,CAAC;QACnC,KAAK,EAAE,CAAC;QADQ,YAAO,GAAP,OAAO,CAAY;QAJ/B,gBAAW,GAAS,IAAI,CAAC;IAMjC,CAAC;IAED;;;OAGG;
|
|
1
|
+
{"version":3,"file":"DeferredSubject.js","sourceRoot":"","sources":["../../lib/DeferredSubject.ts"],"names":[],"mappings":"AACA,O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ACJ","sourcesContent":["import type { Observer, Subscription } from './Subject';\nimport Subject from './Subject';\n\nexport type Tick = null | number | NodeJS.Timer;\n\n/**\n * Subject for a single location and its observers\n *\n * Observers are callbacks provided by the different instances of a location that want to be notified\n * when a list of descriptors changed and is available to be rendered.\n */\nexport default class DeferredSubject<T> extends Subject<T> {\n private notifyTimer: Tick = null;\n\n private lastPayload!: T;\n\n constructor(private timeout: number = 0) {\n super();\n }\n\n /**\n * @Override\n * Notify all observers with a list of descriptors. Send the last value sent if no value is provided.\n */\n public override notify(payload: T) {\n this.clearTimer();\n this.lastPayload = payload;\n\n // The resources for a specific location will be loaded all at once.\n // We defer updating the observers until the last such update made it in\n // so we dont call observers overly often, which could result in a waste of expensive calculations.\n this.notifyTimer = setTimeout(() => {\n this.flush();\n }, this.timeout);\n }\n\n protected clearTimer() {\n clearTimeout(this.notifyTimer as number);\n this.notifyTimer = null;\n }\n\n protected flush() {\n this.clearTimer();\n this.observers.forEach((observer) => observer(this.lastPayload));\n }\n\n /**\n * @Override\n * Add an observer to the location subject. The observer will be notified each time there's a new list of\n * descriptors ready to be renderer.\n */\n override subscribe(observer: Observer<T>): Subscription {\n this.observers.push(observer);\n\n // no notify timer is running - otherwise just wait for the cycle to update the location observer\n const noNotifyTimer = this.notifyTimer === null;\n if (this.lastPayload !== undefined && noNotifyTimer) {\n observer(this.lastPayload);\n }\n\n return {\n unsubscribe: () => this.unsubscribe(observer),\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReplaySubject.js","sourceRoot":"","sources":["../../lib/ReplaySubject.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,aAAiB,SAAQ,OAAU;IAKpD,YAAY,aAAqB,EAAE;QAC/B,KAAK,EAAE,CAAC;QALJ,iBAAY,GAAQ,EAAE,CAAC;QAM3B,IAAI,CAAC,UAAU,GAAG,IAAI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C,QAAQ,CAAC,OAAO,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,KAAK;QACD,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IACjC,CAAC;CACJ","sourcesContent":["import type { Observer, Subscription } from './Subject';\nimport Subject from './Subject';\n\n/**\n * Subject for a single location and its observers\n *\n * Observers are callbacks provided by the different instances of a location that want to be notified\n * when a list of descriptors changed and is available to be rendered.\n */\nexport default class ReplaySubject<T> extends Subject<T> {\n private lastPayloads: T[] = [];\n\n private readonly replaySize: number;\n\n constructor(replaySize: number = 10) {\n super();\n this.replaySize = Math.abs(replaySize);\n }\n\n private addPayload(payload: T) {\n this.lastPayloads.push(payload);\n if (this.lastPayloads.length > this.replaySize) {\n this.lastPayloads = this.lastPayloads.slice(-this.replaySize);\n }\n }\n\n /**\n * @Override\n * Notify all observers with a list of descriptors. Send the last value sent if no value is provided.\n */\n public override notify(payload: T) {\n this.addPayload(payload);\n super.notify(payload);\n }\n\n /**\n * @Override\n * Add an observer to the location subject. The observer will be notified each time there's a new list of\n * descriptors ready to be renderer.\n */\n override subscribe(observer: Observer<T>): Subscription {\n this.lastPayloads.forEach((payload) => {\n observer(payload);\n });\n\n return super.subscribe(observer);\n }\n\n prune() {\n this.lastPayloads.length = 0;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeferredSubject.d.ts","sourceRoot":"","sources":["../../lib/DeferredSubject.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,oBAAY,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IAK1C,OAAO,CAAC,OAAO;IAJ3B,OAAO,CAAC,WAAW,CAAc;IAEjC,OAAO,CAAC,WAAW,CAAK;gBAEJ,OAAO,GAAE,MAAU;IAIvC;;;OAGG;
|
|
1
|
+
{"version":3,"file":"DeferredSubject.d.ts","sourceRoot":"","sources":["../../lib/DeferredSubject.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,oBAAY,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IAK1C,OAAO,CAAC,OAAO;IAJ3B,OAAO,CAAC,WAAW,CAAc;IAEjC,OAAO,CAAC,WAAW,CAAK;gBAEJ,OAAO,GAAE,MAAU;IAIvC;;;OAGG;IACa,MAAM,CAAC,OAAO,EAAE,CAAC;IAYjC,SAAS,CAAC,UAAU;IAKpB,SAAS,CAAC,KAAK;IAKf;;;;OAIG;IACM,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,YAAY;CAa1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReplaySubject.d.ts","sourceRoot":"","sources":["../../lib/ReplaySubject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,YAAY,CAAW;IAE/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,UAAU,GAAE,MAAW;IAKnC,OAAO,CAAC,UAAU;IAOlB;;;OAGG;
|
|
1
|
+
{"version":3,"file":"ReplaySubject.d.ts","sourceRoot":"","sources":["../../lib/ReplaySubject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,YAAY,CAAW;IAE/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,UAAU,GAAE,MAAW;IAKnC,OAAO,CAAC,UAAU;IAOlB;;;OAGG;IACa,MAAM,CAAC,OAAO,EAAE,CAAC;IAKjC;;;;OAIG;IACM,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,YAAY;IAQvD,KAAK;CAGR"}
|
package/lib/DeferredSubject.ts
CHANGED
|
@@ -22,7 +22,7 @@ export default class DeferredSubject<T> extends Subject<T> {
|
|
|
22
22
|
* @Override
|
|
23
23
|
* Notify all observers with a list of descriptors. Send the last value sent if no value is provided.
|
|
24
24
|
*/
|
|
25
|
-
public notify(payload: T) {
|
|
25
|
+
public override notify(payload: T) {
|
|
26
26
|
this.clearTimer();
|
|
27
27
|
this.lastPayload = payload;
|
|
28
28
|
|
|
@@ -49,7 +49,7 @@ export default class DeferredSubject<T> extends Subject<T> {
|
|
|
49
49
|
* Add an observer to the location subject. The observer will be notified each time there's a new list of
|
|
50
50
|
* descriptors ready to be renderer.
|
|
51
51
|
*/
|
|
52
|
-
subscribe(observer: Observer<T>): Subscription {
|
|
52
|
+
override subscribe(observer: Observer<T>): Subscription {
|
|
53
53
|
this.observers.push(observer);
|
|
54
54
|
|
|
55
55
|
// no notify timer is running - otherwise just wait for the cycle to update the location observer
|
package/lib/ReplaySubject.ts
CHANGED
|
@@ -28,7 +28,7 @@ export default class ReplaySubject<T> extends Subject<T> {
|
|
|
28
28
|
* @Override
|
|
29
29
|
* Notify all observers with a list of descriptors. Send the last value sent if no value is provided.
|
|
30
30
|
*/
|
|
31
|
-
public notify(payload: T) {
|
|
31
|
+
public override notify(payload: T) {
|
|
32
32
|
this.addPayload(payload);
|
|
33
33
|
super.notify(payload);
|
|
34
34
|
}
|
|
@@ -38,7 +38,7 @@ export default class ReplaySubject<T> extends Subject<T> {
|
|
|
38
38
|
* Add an observer to the location subject. The observer will be notified each time there's a new list of
|
|
39
39
|
* descriptors ready to be renderer.
|
|
40
40
|
*/
|
|
41
|
-
subscribe(observer: Observer<T>): Subscription {
|
|
41
|
+
override subscribe(observer: Observer<T>): Subscription {
|
|
42
42
|
this.lastPayloads.forEach((payload) => {
|
|
43
43
|
observer(payload);
|
|
44
44
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlassian/clientside-extensions-base",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0-84fa90d-kwd5ix2w",
|
|
4
4
|
"description": "Shared base components and utilities for Client-side extensions",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"homepage": "https://bitbucket.org/atlassian/atlassian-clientside-extensions#readme",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"build": "yarn build:esm && yarn build:cjs",
|
|
60
60
|
"build:esm": "tsc -p tsconfig.json",
|
|
61
61
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
62
|
+
"verify": "tsc --noEmit -p tsconfig.all.json",
|
|
62
63
|
"watch": "tsc --watch",
|
|
63
64
|
"test": "jest",
|
|
64
65
|
"test:watch": "jest --watch"
|
|
@@ -69,5 +70,5 @@
|
|
|
69
70
|
"engines": {
|
|
70
71
|
"node": ">=12.19.0"
|
|
71
72
|
},
|
|
72
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "84fa90d805babbfd94e536dcc1bb4facd1dc4f59"
|
|
73
74
|
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const DeferredSubject_1 = tslib_1.__importDefault(require("./DeferredSubject"));
|
|
5
|
-
jest.useFakeTimers();
|
|
6
|
-
describe('DeferredSubject', () => {
|
|
7
|
-
let subject;
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
subject = new DeferredSubject_1.default();
|
|
10
|
-
});
|
|
11
|
-
it('should defer notifying each observer', () => {
|
|
12
|
-
const TEST_PAYLOAD = true;
|
|
13
|
-
const observer1 = jest.fn();
|
|
14
|
-
const observer2 = jest.fn();
|
|
15
|
-
subject.subscribe(observer1);
|
|
16
|
-
subject.subscribe(observer2);
|
|
17
|
-
subject.notify(TEST_PAYLOAD);
|
|
18
|
-
expect(observer1).not.toHaveBeenCalled();
|
|
19
|
-
expect(observer2).not.toHaveBeenCalled();
|
|
20
|
-
jest.runAllTimers();
|
|
21
|
-
expect(observer1).toHaveBeenCalledWith(TEST_PAYLOAD);
|
|
22
|
-
expect(observer2).toHaveBeenCalledWith(TEST_PAYLOAD);
|
|
23
|
-
});
|
|
24
|
-
it('should defer notifying observers when calling notify consecutive times', () => {
|
|
25
|
-
const TEST_PAYLOAD = true;
|
|
26
|
-
const observer1 = jest.fn();
|
|
27
|
-
subject.subscribe(observer1);
|
|
28
|
-
subject.notify(TEST_PAYLOAD);
|
|
29
|
-
expect(observer1).not.toHaveBeenCalled();
|
|
30
|
-
jest.runAllTimers();
|
|
31
|
-
expect(observer1).toHaveBeenCalledTimes(1);
|
|
32
|
-
// "random" amount of immediate subsequent calls
|
|
33
|
-
subject.notify(TEST_PAYLOAD);
|
|
34
|
-
subject.notify(TEST_PAYLOAD);
|
|
35
|
-
subject.notify(TEST_PAYLOAD);
|
|
36
|
-
subject.notify(TEST_PAYLOAD);
|
|
37
|
-
subject.notify(TEST_PAYLOAD);
|
|
38
|
-
jest.runAllTimers();
|
|
39
|
-
expect(observer1).toHaveBeenCalledTimes(2);
|
|
40
|
-
});
|
|
41
|
-
it('should immediately call late subscribers with the last payload if no timer is running', () => {
|
|
42
|
-
const TEST_PAYLOAD = false;
|
|
43
|
-
const preNotifyObserver = jest.fn();
|
|
44
|
-
const postNotifyObserver = jest.fn();
|
|
45
|
-
// no notifications yet
|
|
46
|
-
subject.subscribe(preNotifyObserver);
|
|
47
|
-
// we register and start the deferred timer
|
|
48
|
-
subject.notify(TEST_PAYLOAD);
|
|
49
|
-
// in the loop waiting to be called
|
|
50
|
-
expect(preNotifyObserver).not.toHaveBeenCalled();
|
|
51
|
-
// run timer
|
|
52
|
-
jest.runAllTimers();
|
|
53
|
-
// should be called now - no more "waiting" happening
|
|
54
|
-
expect(preNotifyObserver).toHaveBeenCalled();
|
|
55
|
-
// should be called immediatelly as no timer is running.
|
|
56
|
-
subject.subscribe(postNotifyObserver);
|
|
57
|
-
expect(postNotifyObserver).toHaveBeenCalled();
|
|
58
|
-
});
|
|
59
|
-
it('should call late subscribers within the same notification loop as other observers if a timer is running', () => {
|
|
60
|
-
const TEST_PAYLOAD = false;
|
|
61
|
-
const preNotifyObserver = jest.fn();
|
|
62
|
-
const postNotifyObserver = jest.fn();
|
|
63
|
-
// no notifications yet
|
|
64
|
-
subject.subscribe(preNotifyObserver);
|
|
65
|
-
// we register and start the deferred timer
|
|
66
|
-
subject.notify(TEST_PAYLOAD);
|
|
67
|
-
// in the loop waiting to be called
|
|
68
|
-
expect(preNotifyObserver).not.toHaveBeenCalled();
|
|
69
|
-
// add late subscriber
|
|
70
|
-
subject.subscribe(postNotifyObserver);
|
|
71
|
-
// should not be called as a timer is running
|
|
72
|
-
expect(postNotifyObserver).not.toHaveBeenCalled();
|
|
73
|
-
// run timer
|
|
74
|
-
jest.runAllTimers();
|
|
75
|
-
expect(preNotifyObserver).toHaveBeenCalled();
|
|
76
|
-
expect(postNotifyObserver).toHaveBeenCalled();
|
|
77
|
-
});
|
|
78
|
-
it('should not call subscribers that deregister before the timer has finished', () => {
|
|
79
|
-
const TEST_PAYLOAD = false;
|
|
80
|
-
const shouldRun = jest.fn();
|
|
81
|
-
const deregistersBeforeRunning = jest.fn();
|
|
82
|
-
// no notifications yet
|
|
83
|
-
subject.subscribe(shouldRun);
|
|
84
|
-
const subscription = subject.subscribe(deregistersBeforeRunning);
|
|
85
|
-
subject.notify(TEST_PAYLOAD);
|
|
86
|
-
expect(shouldRun).not.toHaveBeenCalled();
|
|
87
|
-
expect(deregistersBeforeRunning).not.toHaveBeenCalled();
|
|
88
|
-
// unregister the `deregistersBeforeRunning`
|
|
89
|
-
subscription.unsubscribe();
|
|
90
|
-
jest.runAllTimers();
|
|
91
|
-
expect(shouldRun).toHaveBeenCalled();
|
|
92
|
-
expect(deregistersBeforeRunning).not.toHaveBeenCalled();
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
//# sourceMappingURL=DeferredSubject.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeferredSubject.test.js","sourceRoot":"","sources":["../../lib/DeferredSubject.test.ts"],"names":[],"mappings":";;;AAAA,gFAAgD;AAEhD,IAAI,CAAC,aAAa,EAAE,CAAC;AAErB,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,IAAI,OAAiC,CAAC;IAEtC,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,GAAG,IAAI,yBAAe,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC5C,MAAM,YAAY,GAAG,IAAI,CAAC;QAE1B,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAC5B,OAAO,CAAC,SAAS,CAAC,SAAS,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AC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAElD,YAAY;QACZ,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,MAAM,CAAC,iBAAiB,CAAC,CAAC,gBAAgB,EAAE,CAAC;QAC7C,MAAM,CAAC,kBAAkB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2EAA2E,EAAE,GAAG,EAAE;QACjF,MAAM,YAAY,GAAG,KAAK,CAAC;QAE3B,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,wBAAwB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAE3C,uBAAuB;QACvB,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7B,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;QAEjE,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC7B,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACzC,MAAM,CAAC,wBAAwB,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACxD,4CAA4C;QAC5C,YAAY,CAAC,WAAW,EAAE,CAAC;QAE3B,IAAI,CAAC,YAAY,EAAE,CAAC;QAEpB,MAAM,CAAC,SAAS,CAAC,CAAC,gBAAgB,EAAE,CAAC;QACrC,MAAM,CAAC,wBAAwB,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import DeferredSubject from './DeferredSubject';\n\njest.useFakeTimers();\n\ndescribe('DeferredSubject', () => {\n let subject: DeferredSubject<boolean>;\n\n beforeEach(() => {\n subject = new DeferredSubject();\n });\n\n it('should defer notifying each observer', () => {\n const TEST_PAYLOAD = true;\n\n const observer1 = jest.fn();\n const observer2 = jest.fn();\n subject.subscribe(observer1);\n subject.subscribe(observer2);\n\n subject.notify(TEST_PAYLOAD);\n expect(observer1).not.toHaveBeenCalled();\n expect(observer2).not.toHaveBeenCalled();\n\n jest.runAllTimers();\n expect(observer1).toHaveBeenCalledWith(TEST_PAYLOAD);\n expect(observer2).toHaveBeenCalledWith(TEST_PAYLOAD);\n });\n\n it('should defer notifying observers when calling notify consecutive times', () => {\n const TEST_PAYLOAD = true;\n\n const observer1 = jest.fn();\n subject.subscribe(observer1);\n\n subject.notify(TEST_PAYLOAD);\n expect(observer1).not.toHaveBeenCalled();\n\n jest.runAllTimers();\n expect(observer1).toHaveBeenCalledTimes(1);\n\n // \"random\" amount of immediate subsequent calls\n subject.notify(TEST_PAYLOAD);\n subject.notify(TEST_PAYLOAD);\n subject.notify(TEST_PAYLOAD);\n subject.notify(TEST_PAYLOAD);\n subject.notify(TEST_PAYLOAD);\n\n jest.runAllTimers();\n expect(observer1).toHaveBeenCalledTimes(2);\n });\n\n it('should immediately call late subscribers with the last payload if no timer is running', () => {\n const TEST_PAYLOAD = false;\n\n const preNotifyObserver = jest.fn();\n const postNotifyObserver = jest.fn();\n\n // no notifications yet\n subject.subscribe(preNotifyObserver);\n\n // we register and start the deferred timer\n subject.notify(TEST_PAYLOAD);\n // in the loop waiting to be called\n expect(preNotifyObserver).not.toHaveBeenCalled();\n\n // run timer\n jest.runAllTimers();\n // should be called now - no more \"waiting\" happening\n expect(preNotifyObserver).toHaveBeenCalled();\n\n // should be called immediatelly as no timer is running.\n subject.subscribe(postNotifyObserver);\n\n expect(postNotifyObserver).toHaveBeenCalled();\n });\n\n it('should call late subscribers within the same notification loop as other observers if a timer is running', () => {\n const TEST_PAYLOAD = false;\n\n const preNotifyObserver = jest.fn();\n const postNotifyObserver = jest.fn();\n\n // no notifications yet\n subject.subscribe(preNotifyObserver);\n\n // we register and start the deferred timer\n subject.notify(TEST_PAYLOAD);\n // in the loop waiting to be called\n expect(preNotifyObserver).not.toHaveBeenCalled();\n\n // add late subscriber\n subject.subscribe(postNotifyObserver);\n // should not be called as a timer is running\n expect(postNotifyObserver).not.toHaveBeenCalled();\n\n // run timer\n jest.runAllTimers();\n expect(preNotifyObserver).toHaveBeenCalled();\n expect(postNotifyObserver).toHaveBeenCalled();\n });\n\n it('should not call subscribers that deregister before the timer has finished', () => {\n const TEST_PAYLOAD = false;\n\n const shouldRun = jest.fn();\n const deregistersBeforeRunning = jest.fn();\n\n // no notifications yet\n subject.subscribe(shouldRun);\n const subscription = subject.subscribe(deregistersBeforeRunning);\n\n subject.notify(TEST_PAYLOAD);\n expect(shouldRun).not.toHaveBeenCalled();\n expect(deregistersBeforeRunning).not.toHaveBeenCalled();\n // unregister the `deregistersBeforeRunning`\n subscription.unsubscribe();\n\n jest.runAllTimers();\n\n expect(shouldRun).toHaveBeenCalled();\n expect(deregistersBeforeRunning).not.toHaveBeenCalled();\n });\n});\n"]}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const ReplaySubject_1 = tslib_1.__importDefault(require("./ReplaySubject"));
|
|
5
|
-
describe('ReplaySubject', () => {
|
|
6
|
-
let subject;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
subject = new ReplaySubject_1.default();
|
|
9
|
-
});
|
|
10
|
-
it('should regularly notify observer with payload', () => {
|
|
11
|
-
// we expect 2 assertions to happen
|
|
12
|
-
expect.assertions(1);
|
|
13
|
-
const TEST_PAYLOAD = 1;
|
|
14
|
-
subject.subscribe((payload) => {
|
|
15
|
-
expect(payload).toBe(TEST_PAYLOAD);
|
|
16
|
-
});
|
|
17
|
-
subject.notify(TEST_PAYLOAD);
|
|
18
|
-
});
|
|
19
|
-
it('should replay previous notifications to new subscribers', () => {
|
|
20
|
-
expect.assertions(10);
|
|
21
|
-
const ALL_PAYLOADS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
22
|
-
ALL_PAYLOADS.forEach((payload) => {
|
|
23
|
-
subject.notify(payload);
|
|
24
|
-
});
|
|
25
|
-
let count = 0;
|
|
26
|
-
subject.subscribe((payload) => {
|
|
27
|
-
expect(payload).toBe(ALL_PAYLOADS[count]);
|
|
28
|
-
count += 1;
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
it('should accept and respect replay length on construction', () => {
|
|
32
|
-
subject = new ReplaySubject_1.default(5);
|
|
33
|
-
const ALL_PAYLOADS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
34
|
-
expect.assertions(5);
|
|
35
|
-
ALL_PAYLOADS.forEach((payload) => {
|
|
36
|
-
subject.notify(payload);
|
|
37
|
-
});
|
|
38
|
-
let count = 5;
|
|
39
|
-
subject.subscribe((payload) => {
|
|
40
|
-
expect(payload).toBe(ALL_PAYLOADS[count]);
|
|
41
|
-
count += 1;
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=ReplaySubject.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReplaySubject.test.js","sourceRoot":"","sources":["../../lib/ReplaySubject.test.ts"],"names":[],"mappings":";;;AAAA,4EAA4C;AAE5C,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC3B,IAAI,OAA8B,CAAC;IAEnC,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,GAAG,IAAI,uBAAa,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACrD,mCAAmC;QACnC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAErB,MAAM,YAAY,GAAG,CAAC,CAAC;QAEvB,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE;YAC1B,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QAEH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AAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1C,KAAK,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import ReplaySubject from './ReplaySubject';\n\ndescribe('ReplaySubject', () => {\n let subject: ReplaySubject<number>;\n\n beforeEach(() => {\n subject = new ReplaySubject();\n });\n\n it('should regularly notify observer with payload', () => {\n // we expect 2 assertions to happen\n expect.assertions(1);\n\n const TEST_PAYLOAD = 1;\n\n subject.subscribe((payload) => {\n expect(payload).toBe(TEST_PAYLOAD);\n });\n\n subject.notify(TEST_PAYLOAD);\n });\n\n it('should replay previous notifications to new subscribers', () => {\n expect.assertions(10);\n const ALL_PAYLOADS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\n\n ALL_PAYLOADS.forEach((payload) => {\n subject.notify(payload);\n });\n\n let count = 0;\n subject.subscribe((payload) => {\n expect(payload).toBe(ALL_PAYLOADS[count]);\n count += 1;\n });\n });\n\n it('should accept and respect replay length on construction', () => {\n subject = new ReplaySubject(5);\n const ALL_PAYLOADS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\n expect.assertions(5);\n\n ALL_PAYLOADS.forEach((payload) => {\n subject.notify(payload);\n });\n\n let count = 5;\n subject.subscribe((payload) => {\n expect(payload).toBe(ALL_PAYLOADS[count]);\n count += 1;\n });\n });\n});\n"]}
|
package/dist/cjs/Subject.test.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const Subject_1 = tslib_1.__importDefault(require("./Subject"));
|
|
5
|
-
describe('Subject', () => {
|
|
6
|
-
let subject;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
subject = new Subject_1.default();
|
|
9
|
-
});
|
|
10
|
-
it('should notify each observer when executed with the given payload', () => {
|
|
11
|
-
// we expect 2 assertions to happen
|
|
12
|
-
expect.assertions(2);
|
|
13
|
-
const TEST_PAYLOAD = true;
|
|
14
|
-
subject.subscribe((payload) => {
|
|
15
|
-
expect(payload).toBe(TEST_PAYLOAD);
|
|
16
|
-
});
|
|
17
|
-
subject.subscribe((payload) => {
|
|
18
|
-
expect(payload).toBe(TEST_PAYLOAD);
|
|
19
|
-
});
|
|
20
|
-
subject.notify(TEST_PAYLOAD);
|
|
21
|
-
});
|
|
22
|
-
it('should stop notifying unsubscribed observers', () => {
|
|
23
|
-
expect.assertions(1);
|
|
24
|
-
let count = 0;
|
|
25
|
-
const subscription = subject.subscribe(() => {
|
|
26
|
-
// this should not be called with the incremented count!
|
|
27
|
-
if (count !== 0) {
|
|
28
|
-
throw new Error('I was not unsubscribed!');
|
|
29
|
-
}
|
|
30
|
-
expect(count).toBe(0);
|
|
31
|
-
subscription.unsubscribe();
|
|
32
|
-
});
|
|
33
|
-
subject.notify(true);
|
|
34
|
-
count += 1;
|
|
35
|
-
subject.notify(true);
|
|
36
|
-
});
|
|
37
|
-
it('should transform the subject into an observable', () => {
|
|
38
|
-
expect.assertions(1);
|
|
39
|
-
const TEST_PAYLOAD = false;
|
|
40
|
-
subject.asObservable().subscribe((payload) => {
|
|
41
|
-
expect(payload).toBe(TEST_PAYLOAD);
|
|
42
|
-
});
|
|
43
|
-
subject.notify(TEST_PAYLOAD);
|
|
44
|
-
});
|
|
45
|
-
it('should start notifying descriptors once subscribed', () => {
|
|
46
|
-
expect.assertions(1);
|
|
47
|
-
const DO_NOT_EXPECT_THIS_PAYLOAD = false;
|
|
48
|
-
const EXPECT_THIS_PAYLOAD = true;
|
|
49
|
-
subject.notify(DO_NOT_EXPECT_THIS_PAYLOAD);
|
|
50
|
-
subject.subscribe((payload) => {
|
|
51
|
-
expect(payload).toBe(EXPECT_THIS_PAYLOAD);
|
|
52
|
-
});
|
|
53
|
-
subject.notify(EXPECT_THI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,CAAC;YACtB,YAAY,CAAC,WAAW,EAAE,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACrB,KAAK,IAAI,CAAC,CAAC;QACX,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACvD,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAErB,MAAM,YAAY,GAAG,KAAK,CAAC;QAE3B,OAAO,CAAC,YAAY,EAAE,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE;YACzC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC1D,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,0BAA0B,GAAG,KAAK,CAAC;QACzC,MAAM,mBAAmB,GAAG,IAAI,CAAC;QAEjC,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;QAC3C,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE;YAC1B,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import Subject from './Subject';\n\ndescribe('Subject', () => {\n let subject: Subject<boolean>;\n\n beforeEach(() => {\n subject = new Subject();\n });\n\n it('should notify each observer when executed with the given payload', () => {\n // we expect 2 assertions to happen\n expect.assertions(2);\n\n const TEST_PAYLOAD = true;\n\n subject.subscribe((payload) => {\n expect(payload).toBe(TEST_PAYLOAD);\n });\n subject.subscribe((payload) => {\n expect(payload).toBe(TEST_PAYLOAD);\n });\n\n subject.notify(TEST_PAYLOAD);\n });\n\n it('should stop notifying unsubscribed observers', () => {\n expect.assertions(1);\n\n let count = 0;\n\n const subscription = subject.subscribe(() => {\n // this should not be called with the incremented count!\n if (count !== 0) {\n throw new Error('I was not unsubscribed!');\n }\n expect(count).toBe(0);\n subscription.unsubscribe();\n });\n\n subject.notify(true);\n count += 1;\n subject.notify(true);\n });\n\n it('should transform the subject into an observable', () => {\n expect.assertions(1);\n\n const TEST_PAYLOAD = false;\n\n subject.asObservable().subscribe((payload) => {\n expect(payload).toBe(TEST_PAYLOAD);\n });\n\n subject.notify(TEST_PAYLOAD);\n });\n\n it('should start notifying descriptors once subscribed', () => {\n expect.assertions(1);\n const DO_NOT_EXPECT_THIS_PAYLOAD = false;\n const EXPECT_THIS_PAYLOAD = true;\n\n subject.notify(DO_NOT_EXPECT_THIS_PAYLOAD);\n subject.subscribe((payload) => {\n expect(payload).toBe(EXPECT_THIS_PAYLOAD);\n });\n subject.notify(EXPECT_THIS_PAYLOAD);\n });\n});\n"]}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import DeferredSubject from './DeferredSubject';
|
|
2
|
-
jest.useFakeTimers();
|
|
3
|
-
describe('DeferredSubject', () => {
|
|
4
|
-
let subject;
|
|
5
|
-
beforeEach(() => {
|
|
6
|
-
subject = new DeferredSubject();
|
|
7
|
-
});
|
|
8
|
-
it('should defer notifying each observer', () => {
|
|
9
|
-
const TEST_PAYLOAD = true;
|
|
10
|
-
const observer1 = jest.fn();
|
|
11
|
-
const observer2 = jest.fn();
|
|
12
|
-
subject.subscribe(observer1);
|
|
13
|
-
subject.subscribe(observer2);
|
|
14
|
-
subject.notify(TEST_PAYLOAD);
|
|
15
|
-
expect(observer1).not.toHaveBeenCalled();
|
|
16
|
-
expect(observer2).not.toHaveBeenCalled();
|
|
17
|
-
jest.runAllTimers();
|
|
18
|
-
expect(observer1).toHaveBeenCalledWith(TEST_PAYLOAD);
|
|
19
|
-
expect(observer2).toHaveBeenCalledWith(TEST_PAYLOAD);
|
|
20
|
-
});
|
|
21
|
-
it('should defer notifying observers when calling notify consecutive times', () => {
|
|
22
|
-
const TEST_PAYLOAD = true;
|
|
23
|
-
const observer1 = jest.fn();
|
|
24
|
-
subject.subscribe(observer1);
|
|
25
|
-
subject.notify(TEST_PAYLOAD);
|
|
26
|
-
expect(observer1).not.toHaveBeenCalled();
|
|
27
|
-
jest.runAllTimers();
|
|
28
|
-
expect(observer1).toHaveBeenCalledTimes(1);
|
|
29
|
-
// "random" amount of immediate subsequent calls
|
|
30
|
-
subject.notify(TEST_PAYLOAD);
|
|
31
|
-
subject.notify(TEST_PAYLOAD);
|
|
32
|
-
subject.notify(TEST_PAYLOAD);
|
|
33
|
-
subject.notify(TEST_PAYLOAD);
|
|
34
|
-
subject.notify(TEST_PAYLOAD);
|
|
35
|
-
jest.runAllTimers();
|
|
36
|
-
expect(observer1).toHaveBeenCalledTimes(2);
|
|
37
|
-
});
|
|
38
|
-
it('should immediately call late subscribers with the last payload if no timer is running', () => {
|
|
39
|
-
const TEST_PAYLOAD = false;
|
|
40
|
-
const preNotifyObserver = jest.fn();
|
|
41
|
-
const postNotifyObserver = jest.fn();
|
|
42
|
-
// no notifications yet
|
|
43
|
-
subject.subscribe(preNotifyObserver);
|
|
44
|
-
// we register and start the deferred timer
|
|
45
|
-
subject.notify(TEST_PAYLOAD);
|
|
46
|
-
// in the loop waiting to be called
|
|
47
|
-
expect(preNotifyObserver).not.toHaveBeenCalled();
|
|
48
|
-
// run timer
|
|
49
|
-
jest.runAllTimers();
|
|
50
|
-
// should be called now - no more "waiting" happening
|
|
51
|
-
expect(preNotifyObserver).toHaveBeenCalled();
|
|
52
|
-
// should be called immediatelly as no timer is running.
|
|
53
|
-
subject.subscribe(postNotifyObserver);
|
|
54
|
-
expect(postNotifyObserver).toHaveBeenCalled();
|
|
55
|
-
});
|
|
56
|
-
it('should call late subscribers within the same notification loop as other observers if a timer is running', () => {
|
|
57
|
-
const TEST_PAYLOAD = false;
|
|
58
|
-
const preNotifyObserver = jest.fn();
|
|
59
|
-
const postNotifyObserver = jest.fn();
|
|
60
|
-
// no notifications yet
|
|
61
|
-
subject.subscribe(preNotifyObserver);
|
|
62
|
-
// we register and start the deferred timer
|
|
63
|
-
subject.notify(TEST_PAYLOAD);
|
|
64
|
-
// in the loop waiting to be called
|
|
65
|
-
expect(preNotifyObserver).not.toHaveBeenCalled();
|
|
66
|
-
// add late subscriber
|
|
67
|
-
subject.subscribe(postNotifyObserver);
|
|
68
|
-
// should not be called as a timer is running
|
|
69
|
-
expect(postNotifyObserver).not.toHaveBeenCalled();
|
|
70
|
-
// run timer
|
|
71
|
-
jest.runAllTimers();
|
|
72
|
-
expect(preNotifyObserver).toHaveBeenCalled();
|
|
73
|
-
expect(postNotifyObserver).toHaveBeenCalled();
|
|
74
|
-
});
|
|
75
|
-
it('should not call subscribers that deregister before the timer has finished', () => {
|
|
76
|
-
const TEST_PAYLOAD = false;
|
|
77
|
-
const shouldRun = jest.fn();
|
|
78
|
-
const deregistersBeforeRunning = jest.fn();
|
|
79
|
-
// no notifications yet
|
|
80
|
-
subject.subscribe(shouldRun);
|
|
81
|
-
const subscription = subject.subscribe(deregistersBeforeRunning);
|
|
82
|
-
subject.notify(TEST_PAYLOAD);
|
|
83
|
-
expect(shouldRun).not.toHaveBeenCalled();
|
|
84
|
-
expect(deregistersBeforeRunning).not.toHaveBeenCalled();
|
|
85
|
-
// unregister the `deregistersBeforeRunning`
|
|
86
|
-
subscription.unsubscribe();
|
|
87
|
-
jest.runAllTimers();
|
|
88
|
-
expect(shouldRun).toHaveBeenCalled();
|
|
89
|
-
expect(deregistersBeforeRunning).not.toHaveBeenCalled();
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
//# sourceMappingURL=DeferredSubject.test.js.map
|
|
@@ -1 +0,0 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,EAAE,CAAC;QACzC,MAAM,CAAC,wBAAwB,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACxD,4CAA4C;QAC5C,YAAY,CAAC,WAAW,EAAE,CAAC;QAE3B,IAAI,CAAC,YAAY,EAAE,CAAC;QAEpB,MAAM,CAAC,SAAS,CAAC,CAAC,gBAAgB,EAAE,CAAC;QACrC,MAAM,CAAC,wBAAwB,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import DeferredSubject from './DeferredSubject';\n\njest.useFakeTimers();\n\ndescribe('DeferredSubject', () => {\n let subject: DeferredSubject<boolean>;\n\n beforeEach(() => {\n subject = new DeferredSubject();\n });\n\n it('should defer notifying each observer', () => {\n const TEST_PAYLOAD = true;\n\n const observer1 = jest.fn();\n const observer2 = jest.fn();\n subject.subscribe(observer1);\n subject.subscribe(observer2);\n\n subject.notify(TEST_PAYLOAD);\n expect(observer1).not.toHaveBeenCalled();\n expect(observer2).not.toHaveBeenCalled();\n\n jest.runAllTimers();\n expect(observer1).toHaveBeenCalledWith(TEST_PAYLOAD);\n expect(observer2).toHaveBeenCalledWith(TEST_PAYLOAD);\n });\n\n it('should defer notifying observers when calling notify consecutive times', () => {\n const TEST_PAYLOAD = true;\n\n const observer1 = jest.fn();\n subject.subscribe(observer1);\n\n subject.notify(TEST_PAYLOAD);\n expect(observer1).not.toHaveBeenCalled();\n\n jest.runAllTimers();\n expect(observer1).toHaveBeenCalledTimes(1);\n\n // \"random\" amount of immediate subsequent calls\n subject.notify(TEST_PAYLOAD);\n subject.notify(TEST_PAYLOAD);\n subject.notify(TEST_PAYLOAD);\n subject.notify(TEST_PAYLOAD);\n subject.notify(TEST_PAYLOAD);\n\n jest.runAllTimers();\n expect(observer1).toHaveBeenCalledTimes(2);\n });\n\n it('should immediately call late subscribers with the last payload if no timer is running', () => {\n const TEST_PAYLOAD = false;\n\n const preNotifyObserver = jest.fn();\n const postNotifyObserver = jest.fn();\n\n // no notifications yet\n subject.subscribe(preNotifyObserver);\n\n // we register and start the deferred timer\n subject.notify(TEST_PAYLOAD);\n // in the loop waiting to be called\n expect(preNotifyObserver).not.toHaveBeenCalled();\n\n // run timer\n jest.runAllTimers();\n // should be called now - no more \"waiting\" happening\n expect(preNotifyObserver).toHaveBeenCalled();\n\n // should be called immediatelly as no timer is running.\n subject.subscribe(postNotifyObserver);\n\n expect(postNotifyObserver).toHaveBeenCalled();\n });\n\n it('should call late subscribers within the same notification loop as other observers if a timer is running', () => {\n const TEST_PAYLOAD = false;\n\n const preNotifyObserver = jest.fn();\n const postNotifyObserver = jest.fn();\n\n // no notifications yet\n subject.subscribe(preNotifyObserver);\n\n // we register and start the deferred timer\n subject.notify(TEST_PAYLOAD);\n // in the loop waiting to be called\n expect(preNotifyObserver).not.toHaveBeenCalled();\n\n // add late subscriber\n subject.subscribe(postNotifyObserver);\n // should not be called as a timer is running\n expect(postNotifyObserver).not.toHaveBeenCalled();\n\n // run timer\n jest.runAllTimers();\n expect(preNotifyObserver).toHaveBeenCalled();\n expect(postNotifyObserver).toHaveBeenCalled();\n });\n\n it('should not call subscribers that deregister before the timer has finished', () => {\n const TEST_PAYLOAD = false;\n\n const shouldRun = jest.fn();\n const deregistersBeforeRunning = jest.fn();\n\n // no notifications yet\n subject.subscribe(shouldRun);\n const subscription = subject.subscribe(deregistersBeforeRunning);\n\n subject.notify(TEST_PAYLOAD);\n expect(shouldRun).not.toHaveBeenCalled();\n expect(deregistersBeforeRunning).not.toHaveBeenCalled();\n // unregister the `deregistersBeforeRunning`\n subscription.unsubscribe();\n\n jest.runAllTimers();\n\n expect(shouldRun).toHaveBeenCalled();\n expect(deregistersBeforeRunning).not.toHaveBeenCalled();\n });\n});\n"]}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import ReplaySubject from './ReplaySubject';
|
|
2
|
-
describe('ReplaySubject', () => {
|
|
3
|
-
let subject;
|
|
4
|
-
beforeEach(() => {
|
|
5
|
-
subject = new ReplaySubject();
|
|
6
|
-
});
|
|
7
|
-
it('should regularly notify observer with payload', () => {
|
|
8
|
-
// we expect 2 assertions to happen
|
|
9
|
-
expect.assertions(1);
|
|
10
|
-
const TEST_PAYLOAD = 1;
|
|
11
|
-
subject.subscribe((payload) => {
|
|
12
|
-
expect(payload).toBe(TEST_PAYLOAD);
|
|
13
|
-
});
|
|
14
|
-
subject.notify(TEST_PAYLOAD);
|
|
15
|
-
});
|
|
16
|
-
it('should replay previous notifications to new subscribers', () => {
|
|
17
|
-
expect.assertions(10);
|
|
18
|
-
const ALL_PAYLOADS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
19
|
-
ALL_PAYLOADS.forEach((payload) => {
|
|
20
|
-
subject.notify(payload);
|
|
21
|
-
});
|
|
22
|
-
let count = 0;
|
|
23
|
-
subject.subscribe((payload) => {
|
|
24
|
-
expect(payload).toBe(ALL_PAYLOADS[count]);
|
|
25
|
-
count += 1;
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
it('should accept and respect replay length on construction', () => {
|
|
29
|
-
subject = new ReplaySubject(5);
|
|
30
|
-
const ALL_PAYLOADS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
31
|
-
expect.assertions(5);
|
|
32
|
-
ALL_PAYLOADS.forEach((payload) => {
|
|
33
|
-
subject.notify(payload);
|
|
34
|
-
});
|
|
35
|
-
let count = 5;
|
|
36
|
-
subject.subscribe((payload) => {
|
|
37
|
-
expect(payload).toBe(ALL_PAYLOADS[count]);
|
|
38
|
-
count += 1;
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
//# sourceMappingURL=ReplaySubject.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReplaySubject.test.js","sourceRoot":"","sources":["../../lib/ReplaySubject.test.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB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,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,YAAY,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACpD,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAErB,YAAY,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE;YAC1B,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1C,KAAK,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import ReplaySubject from './ReplaySubject';\n\ndescribe('ReplaySubject', () => {\n let subject: ReplaySubject<number>;\n\n beforeEach(() => {\n subject = new ReplaySubject();\n });\n\n it('should regularly notify observer with payload', () => {\n // we expect 2 assertions to happen\n expect.assertions(1);\n\n const TEST_PAYLOAD = 1;\n\n subject.subscribe((payload) => {\n expect(payload).toBe(TEST_PAYLOAD);\n });\n\n subject.notify(TEST_PAYLOAD);\n });\n\n it('should replay previous notifications to new subscribers', () => {\n expect.assertions(10);\n const ALL_PAYLOADS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\n\n ALL_PAYLOADS.forEach((payload) => {\n subject.notify(payload);\n });\n\n let count = 0;\n subject.subscribe((payload) => {\n expect(payload).toBe(ALL_PAYLOADS[count]);\n count += 1;\n });\n });\n\n it('should accept and respect replay length on construction', () => {\n subject = new ReplaySubject(5);\n const ALL_PAYLOADS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\n expect.assertions(5);\n\n ALL_PAYLOADS.forEach((payload) => {\n subject.notify(payload);\n });\n\n let count = 5;\n subject.subscribe((payload) => {\n expect(payload).toBe(ALL_PAYLOADS[count]);\n count += 1;\n });\n });\n});\n"]}
|
package/dist/esm/Subject.test.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import Subject from './Subject';
|
|
2
|
-
describe('Subject', () => {
|
|
3
|
-
let subject;
|
|
4
|
-
beforeEach(() => {
|
|
5
|
-
subject = new Subject();
|
|
6
|
-
});
|
|
7
|
-
it('should notify each observer when executed with the given payload', () => {
|
|
8
|
-
// we expect 2 assertions to happen
|
|
9
|
-
expect.assertions(2);
|
|
10
|
-
const TEST_PAYLOAD = true;
|
|
11
|
-
subject.subscribe((payload) => {
|
|
12
|
-
expect(payload).toBe(TEST_PAYLOAD);
|
|
13
|
-
});
|
|
14
|
-
subject.subscribe((payload) => {
|
|
15
|
-
expect(payload).toBe(TEST_PAYLOAD);
|
|
16
|
-
});
|
|
17
|
-
subject.notify(TEST_PAYLOAD);
|
|
18
|
-
});
|
|
19
|
-
it('should stop notifying unsubscribed observers', () => {
|
|
20
|
-
expect.assertions(1);
|
|
21
|
-
let count = 0;
|
|
22
|
-
const subscription = subject.subscribe(() => {
|
|
23
|
-
// this should not be called with the incremented count!
|
|
24
|
-
if (count !== 0) {
|
|
25
|
-
throw new Error('I was not unsubscribed!');
|
|
26
|
-
}
|
|
27
|
-
expect(count).toBe(0);
|
|
28
|
-
subscription.unsubscribe();
|
|
29
|
-
});
|
|
30
|
-
subject.notify(true);
|
|
31
|
-
count += 1;
|
|
32
|
-
subject.notify(true);
|
|
33
|
-
});
|
|
34
|
-
it('should transform the subject into an observable', () => {
|
|
35
|
-
expect.assertions(1);
|
|
36
|
-
const TEST_PAYLOAD = false;
|
|
37
|
-
subject.asObservable().subscribe((payload) => {
|
|
38
|
-
expect(payload).toBe(TEST_PAYLOAD);
|
|
39
|
-
});
|
|
40
|
-
subject.notify(TEST_PAYLOAD);
|
|
41
|
-
});
|
|
42
|
-
it('should start notifying descriptors once subscribed', () => {
|
|
43
|
-
expect.assertions(1);
|
|
44
|
-
const DO_NOT_EXPECT_THIS_PAYLOAD = false;
|
|
45
|
-
const EXPECT_THIS_PAYLOAD = true;
|
|
46
|
-
subject.notify(DO_NOT_EXPECT_THIS_PAYLOAD);
|
|
47
|
-
subject.subscribe((payload) => {
|
|
48
|
-
expect(payload).toBe(EXPECT_THIS_PAYLOAD);
|
|
49
|
-
});
|
|
50
|
-
subject.notify(EXPECT_THIS_PAYLOAD);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
//# sourceMappingURL=Subject.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Subject.test.js","sourceRoot":"","sources":["../../lib/Subject.test.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACrB,IAAI,OAAyB,CAAC;IAE9B,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QACxE,mCAAmC;QACnC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAErB,MAAM,YAAY,GAAG,IAAI,CAAC;QAE1B,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE;YAC1B,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE;YAC1B,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACjC,CAA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C1B,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import Subject from './Subject';\n\ndescribe('Subject', () => {\n let subject: Subject<boolean>;\n\n beforeEach(() => {\n subject = new Subject();\n });\n\n it('should notify each observer when executed with the given payload', () => {\n // we expect 2 assertions to happen\n expect.assertions(2);\n\n const TEST_PAYLOAD = true;\n\n subject.subscribe((payload) => {\n expect(payload).toBe(TEST_PAYLOAD);\n });\n subject.subscribe((payload) => {\n expect(payload).toBe(TEST_PAYLOAD);\n });\n\n subject.notify(TEST_PAYLOAD);\n });\n\n it('should stop notifying unsubscribed observers', () => {\n expect.assertions(1);\n\n let count = 0;\n\n const subscription = subject.subscribe(() => {\n // this should not be called with the incremented count!\n if (count !== 0) {\n throw new Error('I was not unsubscribed!');\n }\n expect(count).toBe(0);\n subscription.unsubscribe();\n });\n\n subject.notify(true);\n count += 1;\n subject.notify(true);\n });\n\n it('should transform the subject into an observable', () => {\n expect.assertions(1);\n\n const TEST_PAYLOAD = false;\n\n subject.asObservable().subscribe((payload) => {\n expect(payload).toBe(TEST_PAYLOAD);\n });\n\n subject.notify(TEST_PAYLOAD);\n });\n\n it('should start notifying descriptors once subscribed', () => {\n expect.assertions(1);\n const DO_NOT_EXPECT_THIS_PAYLOAD = false;\n const EXPECT_THIS_PAYLOAD = true;\n\n subject.notify(DO_NOT_EXPECT_THIS_PAYLOAD);\n subject.subscribe((payload) => {\n expect(payload).toBe(EXPECT_THIS_PAYLOAD);\n });\n subject.notify(EXPECT_THIS_PAYLOAD);\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeferredSubject.test.d.ts","sourceRoot":"","sources":["../../lib/DeferredSubject.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReplaySubject.test.d.ts","sourceRoot":"","sources":["../../lib/ReplaySubject.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Subject.test.d.ts","sourceRoot":"","sources":["../../lib/Subject.test.ts"],"names":[],"mappings":""}
|