-
Notifications
You must be signed in to change notification settings - Fork 603
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
Added spaced
function, similar to metered
but waiting
#2684
Conversation
spaced
function, similar to metered
but waiting
Perhaps a Boolean parameter
I can suggest some changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, while writing that documentation suggestion, it just came to me...
How would this combinator differ from just doing the following?
stream.evalTap(_ => Temporal[F].sleep(delay))
(trying to remember the Temporal
api as I can)
As described in the long comment, the purpose of metered
is to make those delays aware and adjusted to other delays in the whole stream, either by the source stream or by the consumer. If this action is to be independent of that context, the evalTap
could do?
The difference between |
@diesalbla I've added a commit to address you suggestion |
* The resulting stream emits the same elements from `this` stream, | ||
* but it emits them in singleton chunks. Between each singleton chunk | ||
* (each element) it introduces a pause that takes the `delay` duration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The resulting stream emits the same elements from `this` stream, | |
* but it emits them in singleton chunks. Between each singleton chunk | |
* (each element) it introduces a pause that takes the `delay` duration. | |
* The resulting stream emits the same elements from `this` stream, | |
* but split into singleton chunks. Between each chunk (element) it | |
* adds a pause of a fixed `delay` duration. |
(slight correction)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eugeniasimich Before merging, could you squash all commits into one?
done! |
While working with the library I was kind of expecting
metered
to behave like the function I add in this PR.In short, the difference between
spaced
andmetered
is analogous to the one betweenfixedDelay
andfixedRate
. I also think having both makes more clear whatmetered
does.Also decided not to have two versions of it (like
metered
andmeteredStartsImmediately
) but that's just an opinion.I can add documentation as well. What do you think?