본문
RxJava2 (from)
RxJava2
from
fromArray
@CheckReturnValue @BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public static <T> Flowable<T> fromArray(T... items)

- Backpressure:
- The operator honors backpressure from downstream and iterates the given
arrayon demand (i.e., when requested). - Scheduler:
fromArraydoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of items in the Array and the type of items to be emitted by the resulting Publisher- Parameters:
items- the array of elements- Returns:
- a Flowable that emits each item in the source Array
- See Also:
- ReactiveX operators documentation: From
fromCallable
@CheckReturnValue @BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public static <T> Flowable<T> fromCallable(java.util.concurrent.Callable<? extends T> supplier)

This allows you to defer the execution of the function you specify until a Subscriber subscribes to the Publisher. That is to say, it makes the function "lazy."
- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
fromCallabledoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of the item emitted by the Publisher- Parameters:
supplier- a function, the execution of which should be deferred;fromCallablewill invoke this function only when a Subscriber subscribes to the Publisher thatfromCallablereturns- Returns:
- a Flowable whose
Subscribers' subscriptions trigger an invocation of the given function - Since:
- 2.0
- See Also:
defer(Callable)
fromFuture
@CheckReturnValue @BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public static <T> Flowable<T> fromFuture(java.util.concurrent.Future<? extends T> future)
Future into a Publisher.
You can convert any object that supports the Future interface into a Publisher that emits the return value of the Future.get() method of that object, by passing the object into the from method.
Important note: This Publisher is blocking on the thread it gets subscribed on; you cannot cancel it.
Unlike 1.x, cancelling the Flowable won't cancel the future. If necessary, one can use composition to achieve the cancellation effect: futurePublisher.doOnCancel(() -> future.cancel(true));.
- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
fromFuturedoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of object that theFuturereturns, and also the type of item to be emitted by the resulting Publisher- Parameters:
future- the sourceFuture- Returns:
- a Flowable that emits the item from the source
Future - See Also:
- ReactiveX operators documentation: From
@CheckReturnValue @BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public static <T> Flowable<T> fromFuture(java.util.concurrent.Future<? extends T> future, long timeout, java.util.concurrent.TimeUnit unit)
Future into a Publisher, with a timeout on the Future.
You can convert any object that supports the Future interface into a Publisher that emits the return value of the Future.get() method of that object, by passing the object into the fromFuture method.
Unlike 1.x, cancelling the Flowable won't cancel the future. If necessary, one can use composition to achieve the cancellation effect: futurePublisher.doOnCancel(() -> future.cancel(true));.
Important note: This Publisher is blocking on the thread it gets subscribed on; you cannot cancel it.
- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
fromFuturedoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of object that theFuturereturns, and also the type of item to be emitted by the resulting Publisher- Parameters:
future- the sourceFuturetimeout- the maximum time to wait before callinggetunit- theTimeUnitof thetimeoutargument- Returns:
- a Flowable that emits the item from the source
Future - See Also:
- ReactiveX operators documentation: From
@CheckReturnValue @BackpressureSupport(value=FULL) @SchedulerSupport(value="custom") public static <T> Flowable<T> fromFuture(java.util.concurrent.Future<? extends T> future, long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Future into a Publisher, with a timeout on the Future.
You can convert any object that supports the Future interface into a Publisher that emits the return value of the Future.get() method of that object, by passing the object into the from method.
Unlike 1.x, cancelling the Flowable won't cancel the future. If necessary, one can use composition to achieve the cancellation effect: futurePublisher.doOnCancel(() -> future.cancel(true));.
Important note: This Publisher is blocking; you cannot cancel it.
- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
fromFuturedoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of object that theFuturereturns, and also the type of item to be emitted by the resulting Publisher- Parameters:
future- the sourceFuturetimeout- the maximum time to wait before callinggetunit- theTimeUnitof thetimeoutargumentscheduler- theSchedulerto wait for the Future on. Use a Scheduler such asSchedulers.io()that can block and wait on the Future- Returns:
- a Flowable that emits the item from the source
Future - See Also:
- ReactiveX operators documentation: From
@CheckReturnValue @BackpressureSupport(value=FULL) @SchedulerSupport(value="custom") public static <T> Flowable<T> fromFuture(java.util.concurrent.Future<? extends T> future, Scheduler scheduler)
Future, operating on a specified Scheduler, into a Publisher.
You can convert any object that supports the Future interface into a Publisher that emits the return value of the Future.get() method of that object, by passing the object into the from method.
Unlike 1.x, cancelling the Flowable won't cancel the future. If necessary, one can use composition to achieve the cancellation effect: futurePublisher.doOnCancel(() -> future.cancel(true));.
- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
- You specify which
Schedulerthis operator will use.
- Type Parameters:
T- the type of object that theFuturereturns, and also the type of item to be emitted by the resulting Publisher- Parameters:
future- the sourceFuturescheduler- theSchedulerto wait for the Future on. Use a Scheduler such asSchedulers.io()that can block and wait on the Future- Returns:
- a Flowable that emits the item from the source
Future - See Also:
- ReactiveX operators documentation: From
fromIterable
@CheckReturnValue @BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public static <T> Flowable<T> fromIterable(java.lang.Iterable<? extends T> source)
Iterable sequence into a Publisher that emits the items in the sequence.
- Backpressure:
- The operator honors backpressure from downstream and iterates the given
iterableon demand (i.e., when requested). - Scheduler:
fromIterabledoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of items in theIterablesequence and the type of items to be emitted by the resulting Publisher- Parameters:
source- the sourceIterablesequence- Returns:
- a Flowable that emits each item in the source
Iterablesequence - See Also:
- ReactiveX operators documentation: From
fromPublisher
@CheckReturnValue @BackpressureSupport(value=PASS_THROUGH) @SchedulerSupport(value="none") public static <T> Flowable<T> fromPublisher(Publisher<? extends T> source)
The Publisher must follow the Reactive-Streams specification. Violating the specification may result in undefined behavior.
If possible, use create(FlowableOnSubscribe, BackpressureStrategy) to create a source-like Flowable instead.
Note that even though Publisher appears to be a functional interface, it is not recommended to implement it through a lambda as the specification requires state management that is not achievable with a stateless lambda.
- Backpressure:
- The operator is a pass-through for backpressure and its behavior is determined by the backpressure behavior of the wrapped publisher.
- Scheduler:
fromPublisherdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the value type of the flow- Parameters:
source- the Publisher to convert- Returns:
- the new Flowable instance
- Throws:
java.lang.NullPointerException- if publisher is null- See Also:
create(FlowableOnSubscribe, BackpressureStrategy)
'Mobile > RxJava2' 카테고리의 다른 글
| 180102(화) - RxJava2 (Just) (0) | 2018.01.02 |
|---|---|
| 171225(월) - RxJava2 (interval) (0) | 2017.12.26 |
| 171215(금) - RxJava2 (empty/never/error) (0) | 2017.12.15 |
| 171214(목) - RxJava2 (defer) (0) | 2017.12.14 |
| 171213(수) - RxJava2 (create) (0) | 2017.12.13 |
댓글