Skip to content

Custom Operator wiki article a little out of sync with practice #2144

Closed
@davidmoten

Description

@davidmoten

The wiki article Implementing Your Own Operators mentions the following:

Your sequence operator should check its Subscriber's isUnsubscribed( ) status before it emits any item to (or sends any notification to) the Subscriber. Do not waste time generating items that no Subscriber is interested in seeing.

This appears to be a pretty conservative approach given that the base operators of RxJava don't follow this uniformly. For example OperatorDistinct, OperatorMap.

Perhaps the article could add that these checks are not essential if for instance better performance was desired and benchmarks indicated that there was a significant advantage to not making the isUnsubscribed() check.

My rule of thumb at the moment is that when I receive a notification to the parent subscriber I check isUnsubscribed() only when that single notification corresponds to multiple notifications to the child subscriber. Does this seem fair?

So I suspect the article could do with a bit of enhancement in this regard. Any more ideas on what to say?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions