Skip to content

Observable.just(T value) and Observable.from(T t1) are confusing #1563

@runningcode

Description

@runningcode

Having Observable.just(T value) and Observable.from(T t1) is confusing to users of the API. It looks like calling Observable.from(T t1) calls Observable.just(T value) internally. The problem is that this method also exists: Observable.from(Iterable<? extends T> iterable). I found myself accidentally passing a list in to Observable.from(T t1)only to find that it took each item in that list and emitted it separately.

This becomes especially confusing when using generics. For example, suppose I have a class Foo<T> which calls Observable.from(T t1) internally. If I create class Foo like Foo<List<Bar>> what happens when it calls Observable.from(T t1) internally? Does it call Observable.from(T t1) or Observable.from(Iterable<? extends T> iterable)?

I suggest removing Observable.from(T t1) or renaming Observable.from(Iterable<? extends T> iterable) to Observable.fromIterable(Iterable<? extends T> iterable).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions