Function to peek emissions and possibly filter them out based on a given predicate.
filter function to decide whether a given emission will actually be emitted