Skip to content

Add version of Observable.just(item) that supports backpressure #3044

@davidmoten

Description

@davidmoten

When I need an Observable for a single value that supports backpressure I normally use Observable.from(Arrays.asList(item)). This carries a bit of overhead and @akarnokd suggested this implementation:

Observable.create(new OnSubscribe<T>() {

            @Override
            public void call(Subscriber<? super T> subscriber) {
                subscriber.setProducer(new SingleProducer<T>(subscriber, defaultValue));
            }});

I'd like to see this in the API and if I assume that the current Observable.just(item) stays as is for performance reasons then what would be a good method name/overload?

Perhaps Observable.just(item, enableBackpressure)? Wont' work because clashes with just(item1, item2).

justWithBackpressure(item) ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions