Closed
Description
When dealing with polymorphic types, I've often had cases where I needed to filter
by a type and then immediately have to follow that with a seemingly-redundant cast
to that type that I've already filtered on. This issue proposes an operator that would add a convenience API for this.
Example:
myMammalObservable
.filter(m -> m instanceof Dog)
.cast(Dog.class)
.subscribe(dog -> dog.playFetch());
Proposal would probably encapsulate that exact logic, though we could combine it into a single operator if there's a perf gain to be had by doing so. Would look like this in use:
myMammalObservable
.filterBy(Dog.class)
.subscribe(dog -> dog.playFetch());
Up for better naming suggestions, just found myself doing this several times in the last week. Totally understand if it's trivial enough not to warrant something on the first-party API. Happy to submit a PR if you'd want it.
Metadata
Metadata
Assignees
Labels
No labels