Observable.of(1, 2, 3)
.subscribe(
l => console.log(l),
noop,
() => console.log('Completed')
);
Observable.just(1, 2, 3)
.doOnComplete(() -> System.out.println("Completed"))
.subscribe(System.out::println);
Output:
1
2
3
Completed
Cold
const textSubject = new Subject<string>();
textSubject.subscribe(
l => console.log(l),
noop,
() => console.log('Completed')
);
textSubject.next('foo');
textSubject.next('bar');
Subject<String> textSubject = PublishSubject.create();
textSubject
.doOnComplete(() -> System.out.println("Completed"))
.subscribe(System.out::println);
textSubject.onNext("foo");
textSubject.onNext("bar");
Output:
foo
bar
No Completed??
const textSubject = new Subject<string>();
textSubject.subscribe(
l => console.log(l),
noop,
() => console.log('Completed')
);
textSubject.complete();
Subject<String> textSubject = PublishSubject.create();
textSubject
.doOnComplete(() -> System.out.println("Completed"))
.subscribe(System.out::println);
textSubject.onComplete();
Output:
Completed
Subjects are closed!
const textSubject = new Subject<string>();
const subscription = textSubject
.delay(100)
.subscribe(
l => console.log(l),
noop,
() => console.log('Completed')
);
textSubject.next('foo');
subscription.unsubscribe();
Subject<String> textSubject = PublishSubject.create();
Disposable disposable = textSubject
.doOnComplete(() -> System.out.println("Completed"))
.delay(100, TimeUnit.MILLISECONDS)
.subscribe(System.out::println);
textSubject.onNext("foo");
disposable.dispose();
Output:
Subscriptions are closed!