Observable

Creates a new Observable

new Observable(observerCallback: Function)
Parameters
observerCallback (Function)
Example
const obs$ = new Observable((observer) => {
  for (let i = 0; i < 10; ++i) {
    observer.next(i);
  }

  observer.complete();
});
const obs$ = Observable.create((observer) => {
  for (let i = 0; i < 10; ++i) {
    observer.next(i);
  }

  observer.complete();
});
Static Members
create(observerCallback)
Instance Members
subscribe(next, error, complete)
subscribe(next = noop, error = noop, complete = noop)

ajax

Make a cancellable XHR request

ajax
Parameters
url (string)
$1 (Object = {})
Name Description
$1.method any (default 'GET')
$1.requestData any (default '')
$1.headers any (default [])
method (string?)
requestData (any?)
headers (Array<{name: string, value: string}>?)
Returns
Observable:

fromEvent

Will create an observable that will listen for an event on a DOM element

Utilizes the makeHot method so that the event does not get reattached on every subscription

fromEvent
Parameters
eventName (string)
element (Element)
mapCallback (Function? = v=>v)
Returns
Observable:

fromPromise

Turns a promise into an observable that emits the value of the promise and then completes

fromPromise
Parameters
promise (Promise)
Returns
Observable:

interval

Creates an interval that will count on every interval tick

interval
Parameters
time (Number) in milliseconds to output the interval count
start (Number? = 0) number to start the interval count at
Returns
Observable:

of

Takes any number of arguments and outputs them in order in an Observable stream

of
Parameters
args (Array<any>)
Returns
Observable:

range

Output a range of numbers to an Observable stream

range
Parameters
$0 (Object = {})
Name Description
$0.start any (default 0)
$0.end any
start (Number?)
end (Number)
Returns
Observable:

Observer

new Observer(observer: {next: Function, error: Function, complete: Function})
Parameters
observer ({next: Function, error: Function, complete: Function} = {})
Instance Members
cleanup()
use(callback)

average

Takes an average of everything coming into the event stream until it completes

average
Parameters
source$ (Observable)
Returns
Observable:

combine

combines multiple observables at the same time. it will only call the observer's next function when all observables have emitted at least one value

combine
Parameters
sources$ (Array<Observable>)
combineCallback (Function = argsCallback)
Returns
Observable:

concat

Concatenate any number of observables together

concat
Parameters
source$ (Observable)
nextSource$ (Observable)
otherSources$ (Array<Observable>)
Returns
Observable:

count

Counts the number of values coming into the stream on complete

count
Parameters
source$ (Observable)
countCallback (Function? = value=>true) a function to use to filter out values that you do not wish to count
Returns
Observable:

debounceTime

Debounces values that will be sent down the stream. Will only output values if there has not been any new values in the past time interval passed

debounceTime
Parameters
source$ (Observable)
time (Number) amount of time in milliseconds
Returns
Observable:

delay

Will delay output from the observable until a specific time interval has passed

delay
Parameters
source$ (Observable)
time (Number) amount of time in milliseconds
Returns
Observable:

doStuff

Will run some callback before passing the current value to the subscription

doStuff
Parameters
source$ (Observable)
runCallback (Function)
Returns
Observable:
Example
doStuff(obs$, (value) => console.log(value))
 .subscribe((sameValue) => console.log('Will log the same value: ', sameValue))l

filter

Will filter out values that you do not want to subscribe to

filter
Parameters
source$ (Observable)
filterCallback (Function)
Returns
Observable:

first

Will take the first value from the observable and then complete This is an alias for take(obs$, 1, callback)

first
Parameters
source$ (Observable)
filterCallback (Function?) filter out values before taking the first one

flatMap

Same as map(obs$, mapCallback) but will take the value of the callback and turn it from an observable to a value

flatMap
Parameters
source$ (Observable)
mapCallback (Function)
Returns
Observable:

map

Will map each value to a new value using the callback

map
Parameters
source$ (Observable)
mapCallback (Function)
Returns
Observable:

max

Will result in the maximum value passed to the observer then will complete

max
Parameters
source$ (Observable)
Returns
Observable:

merge

Will merge any number of observables into one observable stream

merge
Parameters
sources$ (Array<Observable>)
Returns
Observable:

min

Will result in the minimum value passed to the observer then will complete

min
Parameters
source$ (any)
Returns
Observable:

reduce

Sort of the same way that Array.reduce works, it will concatenate all of the values passing through an Observable event stream with a given scanCallback

reduce
Parameters
source$ (Observable)
scanCallback (Function)
startValue (any?)
Returns
Observable:

scan

scan
Parameters
source$ (Observable)
scanCallback (Function)
startValue (any?)
Returns
Observable:

sum

Sums all the values of an observable upon completion

sum
Parameters
source$ (Observable)

switchMap

The value from the mapCallback is an observable and if another value comes through the previous observable is cancelled
This is useful for things like typeaheads where you dont want a request for every keypress

switchMap
Parameters
source$ (Observable)
mapCallback (Function)
Returns
Observable:

take

Takes a number of values that satisfy the filterCallback then completes

take
Parameters
source$ (Observable)
amount (Number)
filterCallback (Function? = ()=>true)
Returns
Observable:

takeUntil

Takes values from the source$ until the takeSource$ emits one value

takeUntil
Parameters
source$ (Observable)
takeSource$ (Observable)
Returns
Observable:

toPromise

Reverse of fromPromise
Converts an Observable to a promise, takes the first value and then completes

toPromise
Parameters
source$ (Observable)
Returns
Promise<any>:

zip

zip
Parameters
sources$ (Observable)
combineCallback (Function = argsCallback)
Returns
Observable:

Subscription

new Subscription(callback: Function, observer: {next: Function, error: Function, complete: Function})
Parameters
callback (Function = noop)
observer ({next: Function, error: Function, complete: Function} = {})
Instance Members
unsubscribe()
isComplete

makeHot

Makes an observable "hot" -- very useful for things like DOM event listeners so that the events do not get bound numerous amounts of times

makeHot
Parameters
cold$ (Observable)
Returns
Observable: