io.reactivex.Observable#never ( )源码实例Demo

下面列出了io.reactivex.Observable#never ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: RxGroups   文件: ObservableGroupTest.java
@Test public void shouldSeparateObservablesByGroupId() {
  ObservableGroup group = observableManager.newGroup();
  ObservableGroup group2 = observableManager.newGroup();
  Observable<String> observable1 = Observable.never();
  Observable<String> observable2 = Observable.never();

  observable1.compose(group.transform(barObserver)).subscribe(barObserver);
  assertThat(group.hasObservables(barObserver)).isEqualTo(true);
  assertThat(group.hasObservables(fooObserver)).isEqualTo(false);
  assertThat(group2.hasObservables(barObserver)).isEqualTo(false);
  assertThat(group2.hasObservables(fooObserver)).isEqualTo(false);

  observable2.compose(group2.transform(fooObserver)).subscribe(fooObserver);
  assertThat(group.hasObservables(barObserver)).isEqualTo(true);
  assertThat(group.hasObservables(fooObserver)).isEqualTo(false);
  assertThat(group2.hasObservables(barObserver)).isEqualTo(false);
  assertThat(group2.hasObservables(fooObserver)).isEqualTo(true);
}
 
源代码2 项目: RxGroups   文件: ObservableGroupTest.java
@Test public void shouldClearObservablesByGroupId() {
  ObservableGroup group = observableManager.newGroup();
  ObservableGroup group2 = observableManager.newGroup();
  Observable<String> observable1 = Observable.never();
  Observable<String> observable2 = Observable.never();

  observable1.compose(group.transform(fooObserver)).subscribe(fooObserver);
  observable2.compose(group2.transform(fooObserver)).subscribe(fooObserver);

  observableManager.destroy(group);

  assertThat(group.hasObservables(fooObserver)).isEqualTo(false);
  assertThat(group2.hasObservables(fooObserver)).isEqualTo(true);
  assertThat(group.subscription(fooObserver)).isNull();
  assertThat(group2.subscription(fooObserver).isCancelled()).isEqualTo(false);

  observableManager.destroy(group2);
  assertThat(group.hasObservables(fooObserver)).isEqualTo(false);
  assertThat(group2.hasObservables(fooObserver)).isEqualTo(false);
  assertThat(group.subscription(fooObserver)).isNull();
  assertThat(group2.subscription(fooObserver)).isNull();
}
 
源代码3 项目: RxGroups   文件: ObservableGroupTest.java
@Test public void shouldClearObservablesWhenLocked() {
  ObservableGroup group = observableManager.newGroup();
  Observable<String> observable1 = Observable.never();
  Observable<String> observable2 = Observable.never();
  TestObserver<String> subscriber1 = new TestObserver<>();
  TestObserver<String> subscriber2 = new TestObserver<>();

  observable1.compose(group.transform(subscriber1)).subscribe(subscriber1);
  observable2.compose(group.transform(subscriber2)).subscribe(subscriber2);

  group.dispose();
  observableManager.destroy(group);

  assertThat(group.hasObservables(fooObserver)).isEqualTo(false);
  assertThat(group.hasObservables(barObserver)).isEqualTo(false);
}
 
@Test
public void test_never() {
	Observable<String> observable = Observable.never();
	TestObserver<String> testObserver = new TestObserver<>();
	observable.subscribe(testObserver);

	testObserver.assertNoValues();
	testObserver.assertTerminated();
	// testObserver.assertComplete();
}
 
源代码5 项目: RxGroups   文件: ObservableGroupTest.java
@Test public void shouldAddRequestByObserverTag() {
  ObservableGroup group = observableManager.newGroup();
  ObservableGroup group2 = observableManager.newGroup();
  Observable<String> sourceObservable = Observable.never();
  sourceObservable.compose(group.transform(fooObserver)).subscribe(fooObserver);

  assertThat(group.hasObservables(fooObserver)).isEqualTo(true);
  assertThat(group2.hasObservables(fooObserver)).isEqualTo(false);
  assertThat(group.hasObservables(barObserver)).isEqualTo(false);
}
 
源代码6 项目: RxGroups   文件: ObservableGroupTest.java
@Test public void shouldNotBeCompleted() {
  ObservableGroup group = observableManager.newGroup();
  TestObserver<Object> subscriber = new TestObserver<>();
  Observable<String> sourceObservable = Observable.never();

  sourceObservable.compose(group.transform(fooObserver)).subscribe(fooObserver);
  subscriber.assertNotComplete();
}
 
源代码7 项目: RxGroups   文件: ObservableGroupTest.java
@Test public void shouldBeSubscribed() {
  ObservableGroup group = observableManager.newGroup();
  Observable<String> sourceObservable = Observable.never();
  sourceObservable.compose(group.transform(fooObserver)).subscribe(fooObserver);

  assertThat(group.subscription(fooObserver).isCancelled()).isEqualTo(false);
}
 
@Override
public Observable<String> methodWhichReturnsAStream() {
    return Observable.never();
}
 
@Override
public Observable<String> methodWhichReturnsAStream() {
    return Observable.never();
}
 
public static void main(String[] args) {
	// TODO Auto-generated method stub
	Observable<String> observable=Observable.never();
	observable.subscribe(item-> System.out.println("we got"+item));
}
 
源代码11 项目: RxAndroidBle   文件: Presenter.java
private static Observable<PresenterEvent> setupNotificationAndIndicationBehaviour(RxBleConnection connection,
                                                                                  BluetoothGattCharacteristic characteristic,
                                                                                  Observable<Boolean> enableNotifyClicks,
                                                                                  Observable<Boolean> enablingNotifyClicks,
                                                                                  Observable<Boolean> disableNotifyClicks,
                                                                                  Observable<Boolean> enableIndicateClicks,
                                                                                  Observable<Boolean> enablingIndicateClicks,
                                                                                  Observable<Boolean> disableIndicateClicks) {
    // checking if characteristic will potentially need a compatibility mode notifications
    final NotificationSetupMode notificationSetupMode =
            characteristic.getDescriptor(clientCharacteristicConfigDescriptorUuid) == null
                    ? NotificationSetupMode.COMPAT
                    : NotificationSetupMode.DEFAULT;
    /*
     * wrapping observables for notifications and indications so they will emit FALSE and TRUE respectively.
     * this is needed because only one of them may be active at the same time and we need to differentiate
     * the clicks
     */
    final Observable<Boolean> enableNotifyClicksObservable = !hasProperty(characteristic, PROPERTY_NOTIFY)
            /*
             * if property for notifications is not available return Observable.never() dummy observable.
             * Observable.never() is needed because of the Observable.amb() below which repeats
             * the behaviour of Observable that first emits or terminates and it will be checking both
             * notifyClicks and indicateClicks
             */
            ? Observable.never()
            // only the first click to enableNotifyClicks is taken to account
            : enableNotifyClicks.take(1).map(aBoolean -> Boolean.FALSE);
    final Observable<Boolean> enableIndicateClicksObservable =
            !hasProperty(characteristic, PROPERTY_INDICATE)
                    ? Observable.never()
                    : enableIndicateClicks.take(1).map(aBoolean -> Boolean.TRUE);

    // checking which notify or indicate will be clicked first the other is unsubscribed on click
    return Observable.amb(asList(
            enableNotifyClicksObservable,
            enableIndicateClicksObservable)
    )
            .flatMap(isIndication -> {
                if (isIndication) { // if indication was clicked
                    return connection
                            // we setup indications
                            .setupIndication(characteristic, notificationSetupMode)
                            // use a convenience transformer for tearing down the notifications
                            .compose(takeUntil(enablingIndicateClicks, disableIndicateClicks))
                            // and wrap the emissions with a convenience function
                            .compose(transformToNotificationPresenterEvent(Type.INDICATE));
                } else { // if notification was clicked
                    return connection
                            .setupNotification(characteristic, notificationSetupMode)
                            .compose(takeUntil(enablingNotifyClicks, disableNotifyClicks))
                            .compose(transformToNotificationPresenterEvent(Type.NOTIFY));
                }
            })
            /*
             * whenever the notification or indication is finished (by the user or an error) repeat from
             * the clicks on notify / indicate
             */
            .compose(repeatAfterCompleted())
            // at the beginning inform the activity about whether compat mode is being used
            .startWith(new CompatibilityModeEvent(
                    hasProperty(characteristic, PROPERTY_NOTIFY | PROPERTY_INDICATE)
                            && notificationSetupMode == NotificationSetupMode.COMPAT
            ));
}
 
源代码12 项目: RxAndroidBle   文件: RxBleConnectionMock.java
@Override
public Observable<ConnectionParameters> observeConnectionParametersUpdates() {
    return Observable.never();
}