Skip to content

OperatorDoEach could do with some work #4260

Closed
@davidmoten

Description

@davidmoten

While looking for emissions after terminal events I was looking at OperatorDoEach which is called by doOnNext, doOnError, doOnCompleted, and doOnEach of course. I noticed these things:

  • lots of wasted allocations per call (use of ActionSubscriber when all that is needed is an ActionObserver) and passing three actions to OperatorDoEach when for three of the four operators we only need one action.
  • it doesn't call RxJavaHooks.error for secondary error emissions from upstream
  • it does call Exceptions.throwIfFatal for all error emissions (do we want to do this generally? I haven't seen it much outside error catching on externally supplied functions or actions)

I'd quite like to see doOnNext and doOnError in particular more efficient because I use them a lot. Should I create dedicated Operator/OnSubscribe classes for the single action operators or perhaps one shared one that has an extra parameter (to indicate what notification type is being used)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions