Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Add StreamGroup.onIdle and StreamGroup.isIdle #164

Merged
merged 5 commits into from
Apr 27, 2021
Merged

Conversation

nex3
Copy link
Contributor

@nex3 nex3 commented Apr 16, 2021

These match the corresponding APIs on FutureGroup.

@nex3 nex3 requested a review from natebosch April 16, 2021 05:41
@google-cla google-cla bot added the cla: yes label Apr 16, 2021
These match the corresponding APIs on FutureGroup.
@nex3 nex3 force-pushed the stream-group-on-idle branch from 89ad01d to 419b7d9 Compare April 16, 2021 05:41

test('emits an event when the group closes', () async {
// It's important that the order of events here stays consistent over
// time, since code may rely on it in subtle ways.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should have any enforced ordering between the stream done and the onIdle done.

cc @lrhn for thoughts on testing behavior that we don't want to make guarantees about.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a difference between "publicly making a guarantee that the behavior will remain consistent", and "internally trying to ensure that the behavior will remain consistent". I agree that you shouldn't advertise this behavior, or consider it part of the public API; however, I think it's worth doing what you can to avoid breaking it accidentally and thereby risking a bunch of subtle bugs without any benefit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honest answer: I'd rather randomize things that people shouldn't depend on, so they can learn to not depend on them. It's a pain to change anything timing related because people have written bad code depending on the implementation, not the specification.

In practice, I'm fine testing that the implementation does what we expect the implementation to do, as long as it's clearly documented that a change of behavior is fine as long as you also change the test. It's often easier to test the actual behavior than test "any of a number of correct behaviors", you'll likelyend up missing some technically correct behaviors anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more explicit documentation.


test('emits an event when the group closes', () async {
// It's important that the order of events here stays consistent over
// time, since code may rely on it in subtle ways.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honest answer: I'd rather randomize things that people shouldn't depend on, so they can learn to not depend on them. It's a pain to change anything timing related because people have written bad code depending on the implementation, not the specification.

In practice, I'm fine testing that the implementation does what we expect the implementation to do, as long as it's clearly documented that a change of behavior is fine as long as you also change the test. It's often easier to test the actual behavior than test "any of a number of correct behaviors", you'll likelyend up missing some technically correct behaviors anyway.

@nex3 nex3 requested review from natebosch and lrhn April 27, 2021 00:46
/// single-subscription group).
///
/// Note that events won't be emitted on this stream until [stream] has been
/// listened to.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth mentioning that the events are delivered asynchronously and the group can have become be non-idle when the event is delivered.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, done.

@nex3 nex3 merged commit 81cc68f into master Apr 27, 2021
@nex3 nex3 deleted the stream-group-on-idle branch April 27, 2021 22:07
mosuem pushed a commit to dart-lang/core that referenced this pull request Oct 14, 2024
These match the corresponding APIs on FutureGroup.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

3 participants