rx.functions.FuncN Java Examples
The following examples show how to use
rx.functions.FuncN.
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: RxUtil.java From ocelli with Apache License 2.0 | 6 votes |
/** * Given a list of observables that emit a boolean condition AND all conditions whenever * any condition changes and emit the resulting condition when the final condition changes. * @param sources * @return */ public static Observable<Boolean> conditionAnder(List<Observable<Boolean>> sources) { return Observable.combineLatest(sources, new FuncN<Observable<Boolean>>() { @Override public Observable<Boolean> call(Object... args) { return Observable.from(args).cast(Boolean.class).firstOrDefault(true, new Func1<Boolean, Boolean>() { @Override public Boolean call(Boolean status) { return !status; } }); } }) .flatMap(new Func1<Observable<Boolean>, Observable<Boolean>>() { @Override public Observable<Boolean> call(Observable<Boolean> t1) { return t1; } }) .distinctUntilChanged(); }
Example #2
Source File: MergeEditUtil.java From Ticket-Analysis with MIT License | 5 votes |
public static Subscription getLimitEnableStateSubscription(View enableView, FuncN<Boolean> funcN, EditText... editTexts) { List<Observable<CharSequence>> observableList = new ArrayList<>(); for (EditText editText : editTexts) { observableList.add(RxTextView.textChanges(editText)); } return Observable.combineLatest(observableList, funcN) .observeOn(AndroidSchedulers.mainThread()) .subscribe(isEnable -> enableView.setEnabled(isEnable), throwable -> enableView.setEnabled(false)); }
Example #3
Source File: Observable.java From letv with Apache License 2.0 | 5 votes |
public static <R> Observable<R> zip(Iterable<? extends Observable<?>> ws, FuncN<? extends R> zipFunction) { List<Observable<?>> os = new ArrayList(); for (Observable<?> o : ws) { os.add(o); } return just(os.toArray(new Observable[os.size()])).lift(new OperatorZip(zipFunction)); }
Example #4
Source File: Observable.java From letv with Apache License 2.0 | 4 votes |
public static <T, R> Observable<R> combineLatest(List<? extends Observable<? extends T>> sources, FuncN<? extends R> combineFunction) { return create(new OnSubscribeCombineLatest(sources, combineFunction)); }
Example #5
Source File: Observable.java From letv with Apache License 2.0 | 4 votes |
public static <T, R> Observable<R> combineLatest(Iterable<? extends Observable<? extends T>> sources, FuncN<? extends R> combineFunction) { return create(new OnSubscribeCombineLatest(sources, combineFunction)); }
Example #6
Source File: Observable.java From letv with Apache License 2.0 | 4 votes |
public static <T, R> Observable<R> combineLatestDelayError(Iterable<? extends Observable<? extends T>> sources, FuncN<? extends R> combineFunction) { return create(new OnSubscribeCombineLatest(null, sources, combineFunction, RxRingBuffer.SIZE, true)); }
Example #7
Source File: Observable.java From letv with Apache License 2.0 | 4 votes |
public static <R> Observable<R> zip(Observable<? extends Observable<?>> ws, FuncN<? extends R> zipFunction) { return ws.toList().map(InternalObservableUtils.TO_ARRAY).lift(new OperatorZip(zipFunction)); }
Example #8
Source File: VaultImpl.java From azure-libraries-for-java with MIT License | 4 votes |
private Observable<List<AccessPolicy>> populateAccessPolicies() { List<Observable<?>> observables = new ArrayList<>(); for (final AccessPolicyImpl accessPolicy : accessPolicies) { if (accessPolicy.objectId() == null) { if (accessPolicy.userPrincipalName() != null) { observables.add(graphRbacManager.users().getByNameAsync(accessPolicy.userPrincipalName()) .subscribeOn(SdkContext.getRxScheduler()).doOnNext(new Action1<ActiveDirectoryUser>() { @Override public void call(ActiveDirectoryUser user) { if (user == null) { throw new CloudException( String.format("User principal name %s is not found in tenant %s", accessPolicy.userPrincipalName(), graphRbacManager.tenantId()), null); } accessPolicy.forObjectId(user.id()); } })); } else if (accessPolicy.servicePrincipalName() != null) { observables.add( graphRbacManager.servicePrincipals().getByNameAsync(accessPolicy.servicePrincipalName()) .subscribeOn(SdkContext.getRxScheduler()).doOnNext(new Action1<ServicePrincipal>() { @Override public void call(ServicePrincipal sp) { if (sp == null) { throw new CloudException(String.format( "Service principal name %s is not found in tenant %s", accessPolicy.servicePrincipalName(), graphRbacManager.tenantId()), null); } accessPolicy.forObjectId(sp.id()); } })); } else { throw new IllegalArgumentException("Access policy must specify object ID."); } } } if (observables.isEmpty()) { return Observable.just(accessPolicies()); } else { return Observable.zip(observables, new FuncN<List<AccessPolicy>>() { @Override public List<AccessPolicy> call(Object... args) { return accessPolicies(); } }); } }
Example #9
Source File: RxHelper.java From sfs with Apache License 2.0 | 4 votes |
private static final <T, R> Observable<R> combineSinglesDelayError(List<? extends Observable<? extends T>> sources, FuncN<? extends R> combineFunction) { return combineLatestDelayError(sources, combineFunction); }