本文整理汇总了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));
}
示例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);
}
}
});
}
示例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);
}
});
}
示例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);
}
示例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);
}
示例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();
}
}));
}
示例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);
}
}
}
});
}
示例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);
}
}
示例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();
}
}));
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
});
}
示例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())));
}
});
}
示例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);
}