Created
December 22, 2014 23:08
-
-
Save NiteshKant/efb62192a637f5a7c279 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2014 Netflix, Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*/ | |
package io.reactivex.netty; | |
import rx.Observable; | |
import rx.Subscriber; | |
import rx.functions.Action0; | |
import rx.functions.Action1; | |
import rx.functions.Func0; | |
import rx.functions.Func1; | |
public class TestFM { | |
public static void main(String[] args) { | |
Observable | |
.create(new Observable.OnSubscribe<Integer>() { | |
@Override | |
public void call(Subscriber<? super Integer> subscriber) { | |
subscriber.onError(new IllegalStateException()); | |
subscriber.onCompleted(); | |
} | |
}) | |
.flatMap(new Func1<Integer, Observable<Integer>>() { | |
@Override | |
public Observable<Integer> call(Integer integer) { | |
return Observable.just(1); | |
} | |
}, new Func1<Throwable, Observable<Integer>>() { | |
@Override | |
public Observable<Integer> call(Throwable throwable) { | |
return Observable.just(2); | |
} | |
}, new Func0<Observable<Integer>>() { | |
@Override | |
public Observable<Integer> call() { | |
return Observable.just(3); | |
} | |
}) | |
.doOnTerminate(new Action0() { | |
@Override | |
public void call() { | |
System.out.println("TestFM.call"); | |
} | |
}) | |
.toBlocking() | |
.forEach(new Action1<Integer>() { | |
@Override | |
public void call(Integer integer) { | |
System.out.println("integer = " + integer); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment