From d10bcae950da64a84337a29863aeec06dee76a72 Mon Sep 17 00:00:00 2001 From: Graham Dennis Date: Mon, 8 May 2017 08:14:10 -0400 Subject: [PATCH 1/2] fix(audit): mirror source if durations are Observable.empty() --- spec/operators/audit-spec.ts | 12 ++++++++++++ src/operator/audit.ts | 3 +++ 2 files changed, 15 insertions(+) diff --git a/spec/operators/audit-spec.ts b/spec/operators/audit-spec.ts index 6f0a455fb2..b151dfef9d 100644 --- a/spec/operators/audit-spec.ts +++ b/spec/operators/audit-spec.ts @@ -127,6 +127,18 @@ describe('Observable.prototype.audit', () => { expectSubscriptions(e1.subscriptions).toBe(e1subs); }); + it('should mirror source if durations are Observable.empty()', () => { + const e1 = hot('abcdefabcdefabcdefabcdefa|'); + const e1subs = '^ !'; + const e2 = Rx.Observable.empty(); + const expected = 'abcdefabcdefabcdefabcdefa|'; + + const result = e1.audit(() => e2); + + expectObservable(result).toBe(expected); + expectSubscriptions(e1.subscriptions).toBe(e1subs); + }); + it('should emit no values if duration is a never', () => { const e1 = hot('----abcdefabcdefabcdefabcdefa|'); const e1subs = '^ !'; diff --git a/src/operator/audit.ts b/src/operator/audit.ts index 41a14bd652..f670346dcb 100644 --- a/src/operator/audit.ts +++ b/src/operator/audit.ts @@ -86,6 +86,9 @@ class AuditSubscriber extends OuterSubscriber { this.destination.error(errorObject.e); } else { this.add(this.throttled = subscribeToResult(this, duration)); + if (this.throttled.closed) { + this.clearThrottle(); + } } } } From 5aaed3053ec3411352ecad26bc4fdd9630192694 Mon Sep 17 00:00:00 2001 From: Graham Dennis Date: Sun, 21 May 2017 12:45:00 +1000 Subject: [PATCH 2/2] refactor(audit): respond to feedback. --- src/operator/audit.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/operator/audit.ts b/src/operator/audit.ts index f670346dcb..c30cd58e0a 100644 --- a/src/operator/audit.ts +++ b/src/operator/audit.ts @@ -85,9 +85,11 @@ class AuditSubscriber extends OuterSubscriber { if (duration === errorObject) { this.destination.error(errorObject.e); } else { - this.add(this.throttled = subscribeToResult(this, duration)); - if (this.throttled.closed) { + const innerSubscription = subscribeToResult(this, duration); + if (innerSubscription.closed) { this.clearThrottle(); + } else { + this.add(this.throttled = innerSubscription); } } }