`find` is a little broken, IMO, and we have work to do with similar operators.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 31.7k
- Forks
- 3k
- PR merge metrics
- No merged PRs in 30d
Description
The current implementation of find is basically first(fn, undefined). It seems like if you don't "find" the item, it should just complete. Otherwise, I'm not sure what differentiates this operate from first and we can probably remove it.
I understand that the current behavior was meant to model Array.prototype.find, but that's a bit different, because it returns T and not T[]... where our find on Observable<T> returns Observable<T | undefined>, which doesn't make sense to me. What if we're literally trying to find undefined? How do I know I found it?
of(1, 2, 3, 4, undefined, 5, 6, 7).pipe(find(x => x === undefined));
I think our options are:
- Deprecate and remove
findand show peoplefirst(fn, undefined)instead. - Fix
findso that it returnsEMPTYif it doesn't "find" anything. Which is a breaking change for some folks for sure.
I'm completely on the fence with this. And maybe we just punt until version 8.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the current find operator and its relationship to first(fn, undefined), then run through the provided example that searches for undefined. The work is complete only after the project decides between removing or deprecating find and changing it to complete with EMPTY, with the resulting Observable behavior clearly defined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100