forked from ReactiveX/RxJava
-
Notifications
You must be signed in to change notification settings - Fork 2
How To Use
benjchristensen edited this page Jan 25, 2013
·
42 revisions
# Hello World!
A requisite "Hello World!" which creates an Observable from a list of Strings, subscribes to the Observable with a function that will print "Hello %!" for each string.
public static void hello(String... names) {
Observable.toObservable(names).subscribe(new Action1<String>() {
@Override
public void call(String s) {
System.out.println("Hello " + s + "!");
}
});
}
hello("Ben", "George");
Hello Ben!
Hello George!
def hello(String[] names) {
Observable.toObservable(names)
.subscribe({ println "Hello " + it + "!"})
}
hello("Ben", "George")
Hello Ben!
Hello George!
(defn hello
[&rest]
(-> (Observable/toObservable &rest)
(.subscribe #(println (str "Hello " % "!")))))
(hello ["Ben" "George"])
Hello Ben!
Hello George!
An observable sequence can
- from existing data
- as an API for async
- Give control of blocking/non-blocking to API
- blocking
- non-blocking
More information can be found on the Observer Pattern page.
OnError subscribe, resume next, delay
A Netflix Original Production
Tech Blog | Twitter @NetflixOSS | Twitter @RxJava | Jobs