Skip to content

Conversation

dignifiedquire
Copy link
Contributor

Closes #14

Copy link

github-actions bot commented Oct 1, 2025

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/n0-watcher/pr/15/docs/n0_watcher/

Last updated: 2025-10-01T09:50:13Z

};
if filtered != self.current {
self.current = filtered.clone();
return Poll::Ready(Ok(filtered));
Copy link

Choose a reason for hiding this comment

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

This behaves a bit different than I would have expected. Filter returns an Option instead of just TheOriginalValue, and will trigger even if the value goes from None to Some and Some to None. I would have expected it to return a Watcher instead.

it is a bit weird for filter to change the type of the stream.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The alternative is to only have filter on watchables that contain Option<T> which is what I had first

Copy link

Choose a reason for hiding this comment

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

Most of our watchers have the value wrapped in an option, right?

I am not sure if this is a good API, but I definitely don't think having a fn filter that changes the stream type is intuitive. Maybe it just needs a different name?

Copy link

Choose a reason for hiding this comment

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

If you were to use this on our watchers in iroh of type Option, you would get an Option<Option>, and initialized would return immediately, possibly returning a None?

I think having this defined only on Optino is less confusing in comparison.

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

Successfully merging this pull request may close these issues.

Implement filter_map on watcher
2 participants