Java Code Examples for io.reactivex.Observable.fromArray()

The following are Jave code examples for showing how to use fromArray() of the io.reactivex.Observable class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitHub   File: ConcatExampleActivity.java   View Source Code Vote up 6 votes
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());
}
 
Example 2
Project: GitHub   File: MergeExampleActivity.java   View Source Code Vote up 5 votes
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());
}
 
Example 3
Project: Reactive-Programming-With-Java-9   File: Demo_sequenceEqual.java   View Source Code Vote up 5 votes
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");
		}
	});
}
 
Example 4
Project: RxJava2-Android-Sample   File: ConcatExampleActivity.java   View Source Code Vote up 5 votes
/**
 * 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());
}
 
Example 5
Project: RxJava2-Android-Sample   File: StartWithExampleActivity.java   View Source Code Vote up 5 votes
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());
}
 
Example 6
Project: RxJava2-Android-Sample   File: CombineLatestExampleActivity.java   View Source Code Vote up 5 votes
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());
}
 
Example 7
Project: RxJava2-Android-Sample   File: MergeExampleActivity.java   View Source Code Vote up 5 votes
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());
}
 
Example 8
Project: Java-EX   File: NullableArray.java   View Source Code Vote up 4 votes
@Override
public Observable<T> observable() {
  return Observable.fromArray(get());
}
 
Example 9
Project: rx-examples-android   File: ZipActivity.java   View Source Code Vote up 4 votes
Observable<Integer> getRollNumber() {
  return Observable.fromArray(12, 15, 63, 15, 54, 92);
}
 
Example 10
Project: Reactive-Programming-With-Java-9   File: Demo_reduce.java   View Source Code Vote up 4 votes
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);

		}
	});

	
               
}
 
Example 11
Project: android-rxmvp-sandbox   File: RxJava.java   View Source Code Vote up 4 votes
Observable<List<String>> query(String text) {
  List<String> alist = new ArrayList<String>();
  alist.add("asdf");
  alist.add("qwer");
  return Observable.fromArray(alist);
}
 
Example 12
Project: RxFamilyUsage-Android   File: RxJava2TransformTest.java   View Source Code Vote up 4 votes
@Before
public void setUp() throws Exception {
    ob = Observable.fromArray(nums);
}
 
Example 13
Project: rx-examples-android   File: ZipActivity.java   View Source Code Vote up 4 votes
Observable<String> getBoyNames() {
  return Observable.fromArray("Manish", "David", "Rohan", "Gurpreet");
}
 
Example 14
Project: RxJava2-Android-Sample   File: FromExampleActivity.java   View Source Code Vote up 4 votes
private Observable<String> getObservable() {
    //
    return Observable.fromArray("a", "b", "c", "d");
}
 
Example 15
Project: rx-examples-android   File: ConcatActivity.java   View Source Code Vote up 4 votes
Observable<String> getBoyNames() {
  return Observable.fromArray("Manish", "David", "Rohan", "Gurpreet");
}
 
Example 16
Project: rx-examples-android   File: ConcatActivity.java   View Source Code Vote up 4 votes
Observable<String> getGirlNames() {
  return Observable.fromArray("Monishaa", "Sonakshi", "Aravi", "Stephanie");
}
 
Example 17
Project: rx-examples-android   File: CombineLatestActivity.java   View Source Code Vote up 4 votes
Observable<String> getBoyNames() {
  return Observable.fromArray("Manish", "David", "Rohan", "Gurpreet");
}
 
Example 18
Project: rx-examples-android   File: CombineLatestActivity.java   View Source Code Vote up 4 votes
Observable<Integer> getRollNumber() {
  return Observable.fromArray(12, 15, 63, 15, 54, 92);
}
 
Example 19
Project: rx-examples-android   File: MergeActivity.java   View Source Code Vote up 4 votes
Observable<String> getBoyNames() {
  return Observable.fromArray("Manish", "David", "Rohan", "Gurpreet");
}
 
Example 20
Project: rx-examples-android   File: MergeActivity.java   View Source Code Vote up 4 votes
Observable<String> getGirlNames() {
  return Observable.fromArray("Monishaa", "Sonakshi", "Aravi", "Stephanie");
}