當前位置: 首頁>>代碼示例>>Java>>正文


Java Func0類代碼示例

本文整理匯總了Java中rx.functions.Func0的典型用法代碼示例。如果您正苦於以下問題:Java Func0類的具體用法?Java Func0怎麽用?Java Func0使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Func0類屬於rx.functions包,在下文中一共展示了Func0類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCompletedRestartableIsUnsubscribed

import rx.functions.Func0; //導入依賴的package包/類
@Test
public void testCompletedRestartableIsUnsubscribed() throws Exception {
    RxPresenter presenter = new RxPresenter();
    presenter.create(null);

    Func0<Subscription> restartable = mock(Func0.class);
    Subscription subscription = mock(Subscription.class);
    when(restartable.call()).thenReturn(subscription);
    when(subscription.isUnsubscribed()).thenReturn(true);

    presenter.restartable(1, restartable);
    assertTrue(presenter.isUnsubscribed(1));
    presenter.start(1);
    assertTrue(presenter.isUnsubscribed(1));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:RxPresenterTest.java

示例2: multicastSelector

import rx.functions.Func0; //導入依賴的package包/類
public static <T, U, R> Observable<R> multicastSelector(final Func0<? extends ConnectableObservable<U>> connectableFactory, final Func1<? super Observable<U>, ? extends Observable<R>> selector) {
    return Observable.create(new Observable$OnSubscribe<R>() {
        public void call(final Subscriber<? super R> child) {
            try {
                ConnectableObservable<U> co = (ConnectableObservable) connectableFactory.call();
                ((Observable) selector.call(co)).subscribe(child);
                co.connect(new Action1<Subscription>() {
                    public void call(Subscription t) {
                        child.add(t);
                    }
                });
            } catch (Throwable e) {
                Exceptions.throwOrReport(e, child);
            }
        }
    });
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:18,代碼來源:OperatorReplay.java

示例3: fromCallable

import rx.functions.Func0; //導入依賴的package包/類
/** As of RxJava 1.1.7, Observable.fromCallable is still @Beta, so just in case... */
@Internal
static <T> Observable<T> fromCallable(final Callable<T> callable) {
    return Observable.defer(new Func0<Observable<T>>() {

        @Override
        public Observable<T> call() {
            T result;
            try {
                result = callable.call();
            } catch (Exception e) {
                return Observable.error(e);
            }
            return Observable.just(result);
        }
    });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:RxUtils.java

示例4: testCompletedRestartable

import rx.functions.Func0; //導入依賴的package包/類
@Test
public void testCompletedRestartable() throws Exception {
    Func0<Subscription> restartable = mock(Func0.class);
    Subscription subscription = mock(Subscription.class);

    RxPresenter presenter = new RxPresenter();
    presenter.create(null);

    when(restartable.call()).thenReturn(subscription);
    when(subscription.isUnsubscribed()).thenReturn(true);
    presenter.restartable(1, restartable);

    verifyNoMoreInteractions(restartable);

    presenter.start(1);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:RxPresenterTest.java

示例5: createResourceResponseObservable

import rx.functions.Func0; //導入依賴的package包/類
private <T extends Resource> Observable<ResourceResponse<T>> createResourceResponseObservable(
        final ImplFunc<ResourceResponse<T>> impl) {
    logger.trace("Creating Observable<ResourceResponse<T>>");
    return Observable.defer(new Func0<Observable<ResourceResponse<T>>>() {

        @Override
        public Observable<ResourceResponse<T>> call() {

            try {
                ResourceResponse<T> rr = impl.invoke();
                return Observable.just(rr);
            } catch (Exception e) {
                return Observable.error(flatten(e));
            }
        }
    }).subscribeOn(scheduler);
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:18,代碼來源:RxWrapperDocumentClientImpl.java

示例6: adapt

import rx.functions.Func0; //導入依賴的package包/類
@Override
public Observable<T> adapt(final Call<T> call) {

    return Observable.<T>create(SyncOnSubscribe.createSingleState(new Func0<Call<T>>() {
        @Override
        public Call<T> call() {
            return call.clone();
        }
    }, new Action2<Call<T>, Observer<? super T>>() {
        @Override
        public void call(Call<T> callClone, Observer<? super T> observer) {
            try {
                observer.onNext(callClone.execute());
                observer.onCompleted();
            } catch (Throwable throwable) {
                observer.onError(throwable);
            }
        }
    }, new Action1<Call<T>>() {
        @Override
        public void call(Call<T> tCall) {
            tCall.cancel();
        }
    }));
}
 
開發者ID:pCloud,項目名稱:pcloud-networking-java,代碼行數:26,代碼來源:RxCallAdapter.java

示例7: invokeAsync

import rx.functions.Func0; //導入依賴的package包/類
/**
 * Invokes tasks in the group.
 *
 * @param context group level shared context that need be passed to invokeAsync(cxt)
 *                method of each task item in the group when it is selected for invocation.
 *
 * @return an observable that emits the result of tasks in the order they finishes.
 */
public Observable<Indexable> invokeAsync(final InvocationContext context) {
    return Observable.defer(new Func0<Observable<Indexable>>() {
        @Override
        public Observable<Indexable> call() {
            if (proxyTaskGroupWrapper.isActive()) {
                return proxyTaskGroupWrapper.taskGroup()
                        .invokeInternAsync(context, true, null);
            } else {
                Set<String> processedKeys = runBeforeGroupInvoke(null);
                if (proxyTaskGroupWrapper.isActive()) {
                    // If proxy got activated after 'runBeforeGroupInvoke()' stage due to the addition of direct
                    // 'postRunDependent's then delegate group invocation to proxy group.
                    //
                    return proxyTaskGroupWrapper.taskGroup()
                            .invokeInternAsync(context, true, processedKeys);
                } else {
                    return invokeInternAsync(context, false, null);
                }
            }
        }
    });
}
 
開發者ID:Azure,項目名稱:azure-libraries-for-java,代碼行數:31,代碼來源:TaskGroup.java

示例8: setImplicitDataDisks

import rx.functions.Func0; //導入依賴的package包/類
private void setImplicitDataDisks(Func0<Integer> nextLun) {
    VirtualMachineScaleSetStorageProfile storageProfile = this.vmss
            .inner()
            .virtualMachineProfile()
            .storageProfile();
    List<VirtualMachineScaleSetDataDisk> dataDisks = storageProfile.dataDisks();
    for (VirtualMachineScaleSetDataDisk dataDisk : this.implicitDisksToAssociate) {
        dataDisk.withCreateOption(DiskCreateOptionTypes.EMPTY);
        if (dataDisk.lun() == -1) {
            dataDisk.withLun(nextLun.call());
        }
        if (dataDisk.managedDisk() == null) {
            dataDisk.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters());
        }
        if (dataDisk.caching() == null) {
            dataDisk.withCaching(getDefaultCachingType());
        }
        if (dataDisk.managedDisk().storageAccountType() == null) {
            dataDisk.managedDisk().withStorageAccountType(getDefaultStorageAccountType());
        }
        dataDisk.withName(null);
        dataDisks.add(dataDisk);
    }
}
 
開發者ID:Azure,項目名稱:azure-libraries-for-java,代碼行數:25,代碼來源:VirtualMachineScaleSetImpl.java

示例9: invokeTaskAsync

import rx.functions.Func0; //導入依賴的package包/類
@Override
public Observable<Indexable> invokeTaskAsync(TaskGroup.InvocationContext context) {
    return Observable.defer(new Func0<Observable<Indexable>>() {
        @Override
        public Observable<Indexable> call() {
            return getMSIExtensionAsync();
        }
    }).flatMap(new Func1<Indexable, Observable<Indexable>>() {
        @Override
        public Observable<Indexable> call(Indexable extension) {
            return updateMSIExtensionAsync((VirtualMachineExtension) extension);
        }
    })
            .switchIfEmpty(Observable.defer(new Func0<Observable<Indexable>>() {
                @Override
                public Observable<Indexable> call() {
                    return installMSIExtensionAsync();
                }
            }));
}
 
開發者ID:Azure,項目名稱:azure-libraries-for-java,代碼行數:21,代碼來源:VirtualMachineMsiHandler.java

示例10: setAttachableNewDataDisks

import rx.functions.Func0; //導入依賴的package包/類
private void setAttachableNewDataDisks(Func0<Integer> nextLun) {
    List<DataDisk> dataDisks = vm.inner().storageProfile().dataDisks();
    for (Map.Entry<String, DataDisk> entry : this.newDisksToAttach.entrySet()) {
        Disk managedDisk = vm.<Disk>taskResult(entry.getKey());
        DataDisk dataDisk = entry.getValue();
        dataDisk.withCreateOption(DiskCreateOptionTypes.ATTACH);
        if (dataDisk.lun() == -1) {
            dataDisk.withLun(nextLun.call());
        }
        dataDisk.withManagedDisk(new ManagedDiskParametersInner());
        dataDisk.managedDisk().withId(managedDisk.id());
        if (dataDisk.caching() == null) {
            dataDisk.withCaching(getDefaultCachingType());
        }
        // Don't set default storage account type for the attachable managed disks, it is already
        // defined in the managed disk and not allowed to change.
        dataDisk.withName(null);
        dataDisks.add(dataDisk);
    }
}
 
開發者ID:Azure,項目名稱:azure-libraries-for-java,代碼行數:21,代碼來源:VirtualMachineImpl.java

示例11: setAttachableExistingDataDisks

import rx.functions.Func0; //導入依賴的package包/類
private void setAttachableExistingDataDisks(Func0<Integer> nextLun) {
    List<DataDisk> dataDisks = vm.inner().storageProfile().dataDisks();
    for (DataDisk dataDisk : this.existingDisksToAttach) {
        dataDisk.withCreateOption(DiskCreateOptionTypes.ATTACH);
        if (dataDisk.lun() == -1) {
            dataDisk.withLun(nextLun.call());
        }
        if (dataDisk.caching() == null) {
            dataDisk.withCaching(getDefaultCachingType());
        }
        // Don't set default storage account type for the attachable managed disks, it is already
        // defined in the managed disk and not allowed to change.
        dataDisk.withName(null);
        dataDisks.add(dataDisk);
    }
}
 
開發者ID:Azure,項目名稱:azure-libraries-for-java,代碼行數:17,代碼來源:VirtualMachineImpl.java

示例12: setImplicitDataDisks

import rx.functions.Func0; //導入依賴的package包/類
private void setImplicitDataDisks(Func0<Integer> nextLun) {
    List<DataDisk> dataDisks = vm.inner().storageProfile().dataDisks();
    for (DataDisk dataDisk : this.implicitDisksToAssociate) {
        dataDisk.withCreateOption(DiskCreateOptionTypes.EMPTY);
        if (dataDisk.lun() == -1) {
            dataDisk.withLun(nextLun.call());
        }
        if (dataDisk.caching() == null) {
            dataDisk.withCaching(getDefaultCachingType());
        }
        if (dataDisk.managedDisk() == null) {
            dataDisk.withManagedDisk(new ManagedDiskParametersInner());
        }
        if (dataDisk.managedDisk().storageAccountType() == null) {
            dataDisk.managedDisk().withStorageAccountType(getDefaultStorageAccountType());
        }
        dataDisk.withName(null);
        dataDisks.add(dataDisk);
    }
}
 
開發者ID:Azure,項目名稱:azure-libraries-for-java,代碼行數:21,代碼來源:VirtualMachineImpl.java

示例13: createResourceAsync

import rx.functions.Func0; //導入依賴的package包/類
@Override
public Observable<DnsZone> createResourceAsync() {
    final DnsZoneImpl self = this;
    Func0<Observable<ZoneInner>> createOrUpdateAsync = new Func0<Observable<ZoneInner>>() {
        @Override
        public Observable<ZoneInner> call() {
            if (self.isInCreateMode()) {
                return self.manager().inner().zones().createOrUpdateAsync(self.resourceGroupName(),
                        self.name(), self.inner(), null/*IfMatch*/, self.dnsZoneETag/*IfNoneMatch*/);
            } else {
                return self.manager().inner().zones().createOrUpdateAsync(self.resourceGroupName(),
                        self.name(), self.inner(), self.dnsZoneETag/*IfMatch*/, null/*IfNoneMatch*/);
            }
        }
    };
    return createOrUpdateAsync.call()
            .map(innerToFluentMap(this))
            .map(new Func1<DnsZone, DnsZone>() {
                @Override
                public DnsZone call(DnsZone dnsZone) {
                    self.dnsZoneETag = null;
                    return dnsZone;
                }
            });
}
 
開發者ID:Azure,項目名稱:azure-libraries-for-java,代碼行數:26,代碼來源:DnsZoneImpl.java

示例14: getStatistics

import rx.functions.Func0; //導入依賴的package包/類
public Observable<MailStatistics> getStatistics() {
  return Observable.defer(new Func0<Observable<MailStatistics>>() {
    @Override public Observable<MailStatistics> call() {

      delay();
      Observable o = checkExceptions();
      if (o != null) {
        return o;
      }

      Map<String, MailsCount> mailsCountMap = new HashMap<String, MailsCount>();

      for (Mail m : mails) {
        MailsCount count = mailsCountMap.get(m.getLabel());
        if (count == null) {
          count = new MailsCount(m.getLabel(), 0);
          mailsCountMap.put(m.getLabel(), count);
        }

        count.incrementCount();
      }

      return Observable.just(
          new MailStatistics(new ArrayList<MailsCount>(mailsCountMap.values())));
    }
  });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:28,代碼來源:MailProvider.java

示例15: getProfileScreens

import rx.functions.Func0; //導入依賴的package包/類
public Observable<List<ProfileScreen>> getProfileScreens(Person person) {

    // TODO throw error from time to time
    return Observable.defer(new Func0<Observable<List<ProfileScreen>>>() {
      @Override public Observable<List<ProfileScreen>> call() {

        List<ProfileScreen> screens = new ArrayList<ProfileScreen>();
        screens.add (new ProfileScreen(ProfileScreen.TYPE_MAILS, "Mails"));
        screens.add(new ProfileScreen(ProfileScreen.TYPE_ABOUT, "About"));

        return Observable.just(screens);
      }
    }).delay(2, TimeUnit.SECONDS);
  }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:ContactsManager.java


注:本文中的rx.functions.Func0類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。