Marble syntax
Throughout this book we will be using marble notation for describing observables and subscribers.
TODO
Marble syntax is a string represents events happening over "time". The first character of any marble string always represents the "zero frame". A "frame" is somewhat analogous to a virtual millisecond.
"-"
time: 10 "frames" of time passage."|"
complete: The successful completion of an observable. This is the observable producer signalingcomplete()
"#"
error: An error terminating the observable. This is the observable producer signalingerror()
"a"
any character: All other characters represent a value being emitted by the producure signalingnext()
"()"
sync groupings: When multiple events need to single in the same frame synchronously, parenthesis are used to group those events. You can group nexted values, a completion or an error in this manner. The position of the initial(
determines the time at which its values are emitted."^"
subscription point: (hot observables only) shows the point at which the tested observables will be subscribed to the hot observable. This is the "zero frame" for that observable, every frame before the^
will be negative.
Examples
'-'
or '------'
: Equivalent to Observable.never()
, or an observable that never emits or completes
|
: Equivalent to Observable.empty()
#
: Equivalent to Observable.throw()
'--a--'
: An observable that waits 20 "frames", emits value a
and then never completes.
'--a--b--|
: On frame 20 emit a
, on frame 50 emit b
, and on frame 80, complete
'--a--b--#
: On frame 20 emit a
, on frame 50 emit b
, and on frame 80, error
'-a-^-b--|
: In a hot observable, on frame -20 emit a
, then on frame 20 emit b
, and on frame 50, complete
.
'--(abc)-|'
: on frame 20, emit a
, b
, and c
, then on frame 80 complete
'-----(a|)'
: on frame 50, emit a
and complete
.
Subscription Marble Syntax
The subscription marble syntax is slightly different to conventional marble syntax. It represents the subscription and an unsubscription points happening over time. There should be no other type of event represented in such diagram.
"-"
time: 10 "frames" of the passage."^"
subscription point: shows the point in time at which a subscription happen."!"
unsubscription point: shows the point in time at which a subscription is unsubscribed.
There should be at most one ^
point in a subscription marble diagram, and at most one !
point. Other than that, the -
character is the only one allowed in a subscription marble diagram.
Examples
'-'
or '------'
: no subscription ever happened.
'--^--'
: a subscription happened after 20 "frames" of time passed, and the subscription was not unsubscribed.
'--^--!-
: on frame 20 a subscription happened, and on frame 50 was unsubscribed.
Sources