Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Latest commit

 

History

History
68 lines (44 loc) · 2.22 KB

Subscriber.md

File metadata and controls

68 lines (44 loc) · 2.22 KB

com.industry.rx_epl.Subscriber <>

A Subscriber contains the callbacks used when a subscription receives a value/error/complete. It is passed to the .subscribe(...) method.

Note: Subscribers should not be reused for multiple subscriptions.

Constructors

# static .create() returns Subscriber <>

Creates a new Subscriber.

Observable.fromValues([1,2,3])
	.subscribe(Subscriber.create().onNext(...).onError(...).onComplete(...));

Methods

# .onNext(callback: action<T>) returns Subscriber <>

Register a callback to be called whenever the subscription receives a value.

action logInteger(integer x) {
	log x.toString();
}

Observable.fromValues([1,2,3])
	.subscribe(Subscriber.create().onNext(logInteger));

# .onComplete(callback: action<>) returns Subscriber <>

Register a callback to be called when the subscription completes.

action logDone() {
	log "Done";
}

Observable.fromValues([1,2,3])
	.subscribe(Subscriber.create().onComplete(logDone));

# .onError(callback: action<E>) returns Subscriber <>

Register a callback to be called when the subscription receives an error. The error can be of any type but is usually com.apama.exceptions.Exception.

Note: The subscription is terminated when an error is received.

Note: If no error handler is registered then the default handler rethrows the exception.

action logError(com.apama.exceptions.Exception e) {
	log e.getMessage();
}

Observable.error()
	.subscribe(Subscriber.create().onError(logError));