Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auditTime does not emit last value #3430

Closed
ronag opened this issue Mar 13, 2018 · 4 comments
Closed

auditTime does not emit last value #3430

ronag opened this issue Mar 13, 2018 · 4 comments

Comments

@ronag
Copy link

ronag commented Mar 13, 2018

Similar to #3351. auditTime does not emit the last value emitted by a completed source.

Looking at the test spec it is not defined if this is the intended behavior or not. However, we've twice encountered this thinking it's very strange behaviour.

> Observable.timer(1000).auditTime(500).subscribe(x => console.log('value', x), undefined, () => console.log('complete')) && null
null
> complete
@benlesh
Copy link
Member

benlesh commented Mar 15, 2018

audit was, by design, made to audit the last value only at the time of audit, not at time of completion... so to make it do this would be a new feature, which I'm open to discussing, but it's not a bug.

@pbadenski
Copy link

Possible duplicate of #1777

@llorenspujol
Copy link

I think this feature is interesting for many things.
auditTime is pretty useful for back-pressuring streams, for example a server-data stream. In this use cases you, almost every time, want to get the last value when this stream completes.

Possible solution:
What about using the same configuration options that throttleTime has? config: {leading: boolean, trailing:boolean} with the defaults to {leading: false, trailing: false}. This way auditTime will still work the same way by default and we would have the ability to emit optionally the leading and trailing stream items.

@cartant
Copy link
Collaborator

cartant commented May 1, 2021

Closing this 'cause, IIRC, the behaviour was changed in v7. See this test:

it('should handle a busy producer emitting a regular repeating sequence', () => {
testScheduler.run(({ hot, time, expectObservable, expectSubscriptions }) => {
const e1 = hot(' abcdefabcdefabcdefabcdefa|');
const e1subs = ' ^------------------------!';
const t = time(' -----| ');
// -----|
// -----|
// -----|
// -----|
const expected = '-----f-----f-----f-----f-----(a|)';
expectObservable(e1.pipe(auditTime(t))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});
});

And this change #5799

@cartant cartant closed this as completed May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants