public static < T , U > StoppableObservable < U > runAsync ( Scheduler scheduler , final Subject < T , U > subject , final Action2 < ? super Observer < ? super T > , ? super Subscription > action ) { final SerialSubscription csub = new SerialSubscription ( ) ; StoppableObservable < U > co = new StoppableObservable < U > ( new Observable . OnSubscribe < U > ( ) { @ Override public void call ( Subscriber < ? super U > t1 ) { subject . subscribe ( t1 ) ; } } , csub ) ; final Worker inner = scheduler . createWorker ( ) ; csub . set ( inner ) ; inner . schedule ( new Action0 ( ) { @ Override public void call ( ) { if ( ! csub . isUnsubscribed ( ) ) { action . call ( subject , csub ) ; } } } ) ; return co ; }
Runs the provided action on the given scheduler and allows propagation of multiple events to the observers of the returned StoppableObservable . The action is immediately executed and unobserved values might be lost depending on the Subject type used .