当前位置: 首页>>代码示例>>Java>>正文


Java Observable.fromArray方法代码示例

本文整理汇总了Java中io.reactivex.Observable.fromArray方法的典型用法代码示例。如果您正苦于以下问题:Java Observable.fromArray方法的具体用法?Java Observable.fromArray怎么用?Java Observable.fromArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.reactivex.Observable的用法示例。


在下文中一共展示了Observable.fromArray方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doSomeWork

import io.reactivex.Observable; //导入方法依赖的package包/类
private void doSomeWork() {
    final String[] aStrings = {"A1", "A2", "A3", "A4"};
    final String[] bStrings = {"B1", "B2", "B3"};

    final Observable<String> aObservable = Observable.fromArray(aStrings);
    final Observable<String> bObservable = Observable.fromArray(bStrings);

    Observable.concat(aObservable, bObservable)
            .subscribe(getObserver());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:ConcatExampleActivity.java

示例2: doSomeWork

import io.reactivex.Observable; //导入方法依赖的package包/类
private void doSomeWork() {
    final String[] aStrings = {"A1", "A2", "A3", "A4"};
    final String[] bStrings = {"B1", "B2", "B3"};

    final Observable<String> aObservable = Observable.fromArray(aStrings);
    final Observable<String> bObservable = Observable.fromArray(bStrings);

    Observable.merge(aObservable, bObservable)
            .subscribe(getObserver());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:MergeExampleActivity.java

示例3: main

import io.reactivex.Observable; //导入方法依赖的package包/类
public static void main(String[] args) {
	// TODO Auto-generated method stub
	Observable names1 = Observable.fromArray(new String[] { "name1", "abc", "xyz", "lmn" });
	Observable names2 = Observable.fromArray(new String[] { "name1", "abc", "xyz", "lmn" });
	Observable.sequenceEqual(names1, names2).subscribe(new SingleObserver<Boolean>() {

		@Override
		public void onError(Throwable throwable) {
			// TODO Auto-generated method stub
			System.out.println(throwable.getMessage());

		}

		@Override
		public void onSubscribe(Disposable disposable) {
			// TODO Auto-generated method stub
			System.out.println("is disposed:-" + disposable.isDisposed());

		}

		@Override
		public void onSuccess(Boolean value) {
			// TODO Auto-generated method stub
			if (value) {
				System.out
						.println("successfully finished comparision of two sequence and both sequences are equal");
			}
			else
			System.out.println("successfully finished comparision of two sequence and both sequences are NOT equal");
		}
	});
}
 
开发者ID:PacktPublishing,项目名称:Reactive-Programming-With-Java-9,代码行数:33,代码来源:Demo_sequenceEqual.java

示例4: doSomeWork

import io.reactivex.Observable; //导入方法依赖的package包/类
/**
 * Concat操作符将多个Observable结合成一个Observable并发射数据,并且严格按照先后顺序发射数据,
 * 前一个Observable的数据没有发射完,是不能发射后面Observable的数据的。
 */
private void doSomeWork() {
    final String[] aStrings = {"A1", "A2", "A3", "A4"};
    final String[] bStrings = {"B1", "B2", "B3"};

    final Observable<String> aObservable = Observable.fromArray(aStrings);
    final Observable<String> bObservable = Observable.fromArray(bStrings);

    Observable.concat(aObservable, bObservable)
            .subscribe(getObserver());
}
 
开发者ID:changjiashuai,项目名称:RxJava2-Android-Sample,代码行数:15,代码来源:ConcatExampleActivity.java

示例5: doSomeWork

import io.reactivex.Observable; //导入方法依赖的package包/类
private void doSomeWork() {
    final String[] aStrings = {"A1", "A2", "A3", "A4"};
    final String[] bStrings = {"B1", "B2", "B3"};

    final Observable<String> aObservable = Observable.fromArray(aStrings);
    final Observable<String> bObservable = Observable.fromArray(bStrings);

    aObservable.startWith(bObservable)
            .subscribe(getObserver());
}
 
开发者ID:changjiashuai,项目名称:RxJava2-Android-Sample,代码行数:11,代码来源:StartWithExampleActivity.java

示例6: doSomeWork

import io.reactivex.Observable; //导入方法依赖的package包/类
private void doSomeWork() {
    final String[] aStrings = {"A1", "A2", "A3", "A4"};
    final String[] bStrings = {"B1", "B2", "B3"};

    final Observable<String> aObservable = Observable.fromArray(aStrings);
    final Observable<String> bObservable = Observable.fromArray(bStrings);

    Observable.combineLatest(aObservable, bObservable, new BiFunction<String, String, String>() {
        @Override
        public String apply(@NonNull String s, @NonNull String s2) throws Exception {
            return s + "-" + s2;
        }
    }).subscribe(getObserver());
}
 
开发者ID:changjiashuai,项目名称:RxJava2-Android-Sample,代码行数:15,代码来源:CombineLatestExampleActivity.java

示例7: observable

import io.reactivex.Observable; //导入方法依赖的package包/类
@Override
public Observable<T> observable() {
  return Observable.fromArray(get());
}
 
开发者ID:XDean,项目名称:Java-EX,代码行数:5,代码来源:NullableArray.java

示例8: getRollNumber

import io.reactivex.Observable; //导入方法依赖的package包/类
Observable<Integer> getRollNumber() {
  return Observable.fromArray(12, 15, 63, 15, 54, 92);
}
 
开发者ID:GurpreetSK95,项目名称:rx-examples-android,代码行数:4,代码来源:ZipActivity.java

示例9: main

import io.reactivex.Observable; //导入方法依赖的package包/类
public static void main(String[] args) {
	Integer[] numbers = { 1, 2, 13, 34, 12, 10 };
	Observable<Integer> source1 = Observable.fromArray(numbers);

	source1.reduce(new BiFunction<Integer, Integer, Integer>() {

		@Override
		public Integer apply(Integer value1, Integer value2) throws Exception {
			// TODO Auto-generated method stub
			// 1, 2, 13, 34, 12, 10
			int sum = 0;
			return value1 + value2;
		}
	}).subscribe(new MaybeObserver<Integer>() {

		@Override
		public void onComplete() {
			// TODO Auto-generated method stub
			System.out.println("completed2");

		}

		@Override
		public void onError(Throwable throwable) {
			// TODO Auto-generated method stub
			System.out.println(throwable.getMessage());

		}

		@Override
		public void onSubscribe(Disposable arg0) {
			// TODO Auto-generated method stub

		}

		@Override
		public void onSuccess(Integer value) {
			// TODO Auto-generated method stub
			System.out.println(value);

		}
	});

	
               
}
 
开发者ID:PacktPublishing,项目名称:Reactive-Programming-With-Java-9,代码行数:47,代码来源:Demo_reduce.java

示例10: query

import io.reactivex.Observable; //导入方法依赖的package包/类
Observable<List<String>> query(String text) {
  List<String> alist = new ArrayList<String>();
  alist.add("asdf");
  alist.add("qwer");
  return Observable.fromArray(alist);
}
 
开发者ID:jimandreas,项目名称:android-rxmvp-sandbox,代码行数:7,代码来源:RxJava.java

示例11: setUp

import io.reactivex.Observable; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    ob = Observable.fromArray(nums);
}
 
开发者ID:qingmei2,项目名称:RxFamilyUsage-Android,代码行数:5,代码来源:RxJava2TransformTest.java

示例12: getBoyNames

import io.reactivex.Observable; //导入方法依赖的package包/类
Observable<String> getBoyNames() {
  return Observable.fromArray("Manish", "David", "Rohan", "Gurpreet");
}
 
开发者ID:GurpreetSK95,项目名称:rx-examples-android,代码行数:4,代码来源:ZipActivity.java

示例13: getObservable

import io.reactivex.Observable; //导入方法依赖的package包/类
private Observable<String> getObservable() {
    //
    return Observable.fromArray("a", "b", "c", "d");
}
 
开发者ID:changjiashuai,项目名称:RxJava2-Android-Sample,代码行数:5,代码来源:FromExampleActivity.java

示例14: getGirlNames

import io.reactivex.Observable; //导入方法依赖的package包/类
Observable<String> getGirlNames() {
  return Observable.fromArray("Monishaa", "Sonakshi", "Aravi", "Stephanie");
}
 
开发者ID:GurpreetSK95,项目名称:rx-examples-android,代码行数:4,代码来源:ConcatActivity.java


注:本文中的io.reactivex.Observable.fromArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。