Java Code Examples for io.reactivex.schedulers.Schedulers.newThread()

The following are Jave code examples for showing how to use newThread() of the io.reactivex.schedulers.Schedulers class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: YiZhi   File: RxBus.java   View Source Code Vote up 6 votes
/**
 * 用于处理订阅事件在那个线程中执行
 *
 * @param observable       d
 * @param subscriberMethod d
 * @return Observable
 */
private Flowable postToObservable(Flowable observable, SubscriberMethod subscriberMethod) {
    Scheduler scheduler;
    switch (subscriberMethod.threadMode) {
        case MAIN:
            scheduler = AndroidSchedulers.mainThread();
            break;

        case NEW_THREAD:
            scheduler = Schedulers.newThread();
            break;

        case CURRENT_THREAD:
            scheduler = Schedulers.trampoline();
            break;
        default:
            throw new IllegalStateException("Unknown thread mode: " + subscriberMethod.threadMode);
    }
    return observable.observeOn(scheduler);
}
 
Example 2
Project: Spring-5.0-Cookbook   File: EmployeeRxJavaServiceImpl.java   View Source Code Vote up 5 votes
@Override
public Flowable<String> getEmpNamesRx() {
	Scheduler observerWorker = Schedulers.single();
	Scheduler subscriberWorker = Schedulers.newThread();
	Function<Employee, String> names = (emp) -> emp.getFirstName() + emp.getLastName();
	Flowable<String> emps = Flowable.fromIterable(employeeDaoImpl.getEmployees())
			.map(names).observeOn(observerWorker).subscribeOn(subscriberWorker);
	return emps;
}
 
Example 3
Project: Reactive-Android-Programming   File: Sandbox.java   View Source Code Vote up 5 votes
private void demo0() {
    Schedulers.single();
    Schedulers.trampoline();
    Schedulers.newThread();
    Schedulers.computation();
    Schedulers.io();
    Schedulers.io();
}
 
Example 4
Project: Reactive-Android-Programming   File: Sandbox.java   View Source Code Vote up 5 votes
private void demo0() {
    Schedulers.single();
    Schedulers.trampoline();
    Schedulers.newThread();
    Schedulers.computation();
    Schedulers.io();
    Schedulers.io();
}
 
Example 5
Project: DiscogsBrowser   File: MySchedulerProvider.java   View Source Code Vote up 4 votes
@Override
public Scheduler newThread()
{
    return Schedulers.newThread();
}
 
Example 6
Project: Melophile   File: SchedulerProvider.java   View Source Code Vote up 4 votes
@NonNull
public Scheduler multi(){
    return Schedulers.newThread();
}
 
Example 7
Project: NYBus   File: SchedulerProviderImplementation.java   View Source Code Vote up 2 votes
/**
 * Provides the new thread Scheduler.
 *
 * @return provides the new thread Scheduler.
 */
@Override
public Scheduler provideNewThreadScheduler() {
    return Schedulers.newThread();
}
 
Example 8
Project: NYBus   File: SchedulerProviderImpl.java   View Source Code Vote up 2 votes
/**
 * Provides the new thread Scheduler.
 *
 * @return provides the new thread Scheduler.
 */
@Override
public Scheduler provideNewThreadScheduler() {
    return Schedulers.newThread();
}