当前位置: 首页>>代码示例>>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;未经允许,请勿转载。