Java Code Examples for io.reactivex.plugins.RxJavaPlugins#setOnMaybeAssembly()

The following examples show how to use io.reactivex.plugins.RxJavaPlugins#setOnMaybeAssembly() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RxJavaAssemblyTracking.java    From RxJava2Debug with Apache License 2.0 6 votes vote down vote up
/**
 * Disable the assembly tracking.
 */
public static void disable() {
    if (lock.compareAndSet(false, true)) {

        RxJavaPlugins.setOnCompletableAssembly(null);
        RxJavaPlugins.setOnSingleAssembly(null);
        RxJavaPlugins.setOnMaybeAssembly(null);

        RxJavaPlugins.setOnObservableAssembly(null);
        RxJavaPlugins.setOnFlowableAssembly(null);
        RxJavaPlugins.setOnConnectableObservableAssembly(null);
        RxJavaPlugins.setOnConnectableFlowableAssembly(null);

        RxJavaPlugins.setOnParallelAssembly(null);

        lock.set(false);
    }
}
 
Example 2
Source File: RequestContextAssembly.java    From armeria with Apache License 2.0 6 votes vote down vote up
/**
 * Disable {@link RequestContext} during operators.
 */
public static synchronized void disable() {
    if (!enabled) {
        return;
    }
    RxJavaPlugins.setOnObservableAssembly(oldOnObservableAssembly);
    oldOnObservableAssembly = null;
    RxJavaPlugins.setOnConnectableObservableAssembly(oldOnConnectableObservableAssembly);
    oldOnConnectableObservableAssembly = null;
    RxJavaPlugins.setOnCompletableAssembly(oldOnCompletableAssembly);
    oldOnCompletableAssembly = null;
    RxJavaPlugins.setOnSingleAssembly(oldOnSingleAssembly);
    oldOnSingleAssembly = null;
    RxJavaPlugins.setOnMaybeAssembly(oldOnMaybeAssembly);
    oldOnMaybeAssembly = null;
    RxJavaPlugins.setOnFlowableAssembly(oldOnFlowableAssembly);
    oldOnFlowableAssembly = null;
    RxJavaPlugins.setOnConnectableFlowableAssembly(oldOnConnectableFlowableAssembly);
    oldOnConnectableFlowableAssembly = null;
    RxJavaPlugins.setOnParallelAssembly(oldOnParallelAssembly);
    oldOnParallelAssembly = null;
    enabled = false;
}
 
Example 3
Source File: AsyncResultTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testMaybe() {
  Promise<String> promise = Promise.promise();
  try {
    Maybe justMe = Maybe.just("me");
    RxJavaPlugins.setOnMaybeAssembly(single -> justMe);
    Maybe<String> maybe = AsyncResultMaybe.toMaybe(promise.future()::onComplete);
    assertSame(maybe, justMe);
  } finally {
    RxJavaPlugins.reset();
  }
}
 
Example 4
Source File: RxJavaHooksUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenMaybe_whenAssembled_shouldExecuteTheHook() {

    RxJavaPlugins.setOnMaybeAssembly(maybe -> {
        hookCalled = true;
        return maybe;
    });

    Maybe.just(1);
    assertTrue(hookCalled);
}
 
Example 5
Source File: CurrentTraceContextAssemblyTracking.java    From brave with Apache License 2.0 5 votes vote down vote up
/** Disables the validation hooks be resetting the assembled hooks to none. */
public static void disable() {
  RxJavaPlugins.setOnCompletableAssembly(null);
  RxJavaPlugins.setOnSingleAssembly(null);
  RxJavaPlugins.setOnMaybeAssembly(null);
  RxJavaPlugins.setOnObservableAssembly(null);
  RxJavaPlugins.setOnFlowableAssembly(null);

  RxJavaPlugins.setOnConnectableObservableAssembly(null);
  RxJavaPlugins.setOnConnectableFlowableAssembly(null);

  RxJavaPlugins.setOnParallelAssembly(null);

  enabled = false;
}