Created
August 19, 2018 09:54
-
-
Save anitaa1990/72bf6d9270fbd75cde2e9f55cd4b055c to your computer and use it in GitHub Desktop.
This file contains 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
Observable.using( | |
new Callable<String>() { | |
@Override | |
public String call() throws Exception { | |
return "Example"; | |
} | |
}, | |
new Function<String, ObservableSource<Character>>() { | |
@Override | |
public ObservableSource<Character> apply(String s) { | |
return Observable.create(o -> { | |
for (Character c : s.toCharArray()) { | |
o.onNext(c); | |
} | |
o.onComplete(); | |
}); | |
} | |
}, | |
new Consumer<String>() { | |
@Override | |
public void accept(String s) { | |
System.out.println("Disposable: " + s); | |
} | |
} | |
) | |
.subscribe(new Observer<Character>() { | |
@Override | |
public void onSubscribe(Disposable d) { | |
} | |
@Override | |
public void onNext(Character character) { | |
System.out.println("onNext: " + character); | |
} | |
@Override | |
public void onError(Throwable e) { | |
} | |
@Override | |
public void onComplete() { | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment