Skip to content

Commit

Permalink
docs(operators): fix ESDoc build to put operators under Observable class
Browse files Browse the repository at this point in the history
This moves operators from being top-level functions (they are not, because they are
added/monkey-patched to the Observable type) to being methods under the Observable class.
  • Loading branch information
staltz committed Feb 23, 2016
1 parent da75eb4 commit 7251390
Show file tree
Hide file tree
Showing 118 changed files with 719 additions and 100 deletions.
3 changes: 3 additions & 0 deletions esdoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"title": "RxJS",
"styles": ["./doc/styles/main.css"],
"index": "./doc/index.md",
"plugins": [
{"name": "./tools/custom-esdoc-plugin.js"}
],
"manual": {
"asset": "./doc/asset",
"overview": [
Expand Down
33 changes: 17 additions & 16 deletions src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ export class Observable<T> implements CoreOperators<T> {

/**
* @constructor
* @param {Function} subscribe the function that is
* called when the Observable is initially subscribed to. This function is given a Subscriber, to which new values
* can be `next`ed, or an `error` method can be called to raise an error, or `complete` can be called to notify
* of a successful completion.
* @param {Function} subscribe the function that is called when the Observable is
* initially subscribed to. This function is given a Subscriber, to which new values
* can be `next`ed, or an `error` method can be called to raise an error, or
* `complete` can be called to notify of a successful completion.
*/
constructor(subscribe?: <R>(subscriber: Subscriber<R>) => Subscription | Function | void) {
if (subscribe) {
Expand All @@ -84,22 +84,23 @@ export class Observable<T> implements CoreOperators<T> {
// HACK: Since TypeScript inherits static properties too, we have to
// fight against TypeScript here so Subject can have a different static create signature
/**
* @static
* Creates a new cold Observable by calling the Observable constructor
* @static true
* @owner Observable
* @method create
* @param {Function} subscribe? the subscriber function to be passed to the Observable constructor
* @returns {Observable} a new cold observable
* @description creates a new cold Observable by calling the Observable constructor
* @return {Observable} a new cold observable
*/
static create: Function = <T>(subscribe?: <R>(subscriber: Subscriber<R>) => Subscription | Function | void) => {
return new Observable<T>(subscribe);
};

/**
* Creates a new Observable, with this Observable as the source, and the passed
* operator defined as the new observable's operator.
* @method lift
* @param {Operator} operator the operator defining the operation to take on the observable
* @returns {Observable} a new observable with the Operator applied
* @description creates a new Observable, with this Observable as the source, and the passed
* operator defined as the new observable's operator.
* @return {Observable} a new observable with the Operator applied
*/
lift<R>(operator: Operator<T, R>): Observable<R> {
const observable = new Observable<R>();
Expand All @@ -109,15 +110,15 @@ export class Observable<T> implements CoreOperators<T> {
}

/**
* Registers handlers for handling emitted values, error and completions from the observable, and
* executes the observable's subscriber function, which will take action to set up the underlying data stream
* @method subscribe
* @param {PartialObserver|Function} observerOrNext (optional) either an observer defining all functions to be called,
* or the first of three possible handlers, which is the handler for each value emitted from the observable.
* @param {Function} error (optional) a handler for a terminal event resulting from an error. If no error handler is provided,
* the error will be thrown as unhandled
* @param {Function} complete (optional) a handler for a terminal event resulting from successful completion.
* @returns {Subscription} a subscription reference to the registered handlers
* @description registers handlers for handling emitted values, error and completions from the observable, and
* executes the observable's subscriber function, which will take action to set up the underlying data stream
* @return {Subscription} a subscription reference to the registered handlers
*/
subscribe(observerOrNext?: PartialObserver<T> | ((value: T) => void),
error?: (error: any) => void,
Expand Down Expand Up @@ -147,7 +148,7 @@ export class Observable<T> implements CoreOperators<T> {
* @param {Function} next a handler for each value emitted by the observable
* @param {any} [thisArg] a `this` context for the `next` handler function
* @param {PromiseConstructor} [PromiseCtor] a constructor function used to instantiate the Promise
* @returns {Promise} a promise that either resolves on observable completion or
* @return {Promise} a promise that either resolves on observable completion or
* rejects with the handled error
*/
forEach(next: (value: T) => void, thisArg: any, PromiseCtor?: typeof Promise): Promise<void> {
Expand Down Expand Up @@ -303,9 +304,9 @@ export class Observable<T> implements CoreOperators<T> {
zipAll: <R>(project?: (...values: Array<any>) => R) => Observable<R>;

/**
* An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable
* @method Symbol.observable
* @returns {Observable} this instance of the observable
* @description an interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable
* @return {Observable} this instance of the observable
*/
[SymbolShim.observable]() {
return this;
Expand Down
18 changes: 18 additions & 0 deletions src/observable/ArrayObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,30 @@ import {Subscriber} from '../Subscriber';
import {isScheduler} from '../util/isScheduler';
import {Subscription} from '../Subscription';

/**
*
*/
export class ArrayObservable<T> extends Observable<T> {

/**
* @param array
* @param scheduler
* @return {ArrayObservable}
* @static true
* @name fromArray
* @owner Observable
*/
static create<T>(array: T[], scheduler?: Scheduler) {
return new ArrayObservable(array, scheduler);
}

/**
* @param array
* @return {any}
* @static true
* @name of
* @owner Observable
*/
static of<T>(...array: Array<T | Scheduler>): Observable<T> {
let scheduler = <Scheduler>array[array.length - 1];
if (isScheduler(scheduler)) {
Expand Down
18 changes: 18 additions & 0 deletions src/observable/BoundCallbackObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import {tryCatch} from '../util/tryCatch';
import {errorObject} from '../util/errorObject';
import {AsyncSubject} from '../subject/AsyncSubject';

/**
*
*/
export class BoundCallbackObservable<T> extends Observable<T> {
subject: AsyncSubject<T>;

Expand All @@ -27,6 +30,21 @@ export class BoundCallbackObservable<T> extends Observable<T> {
static create<T>(callbackFunc: Function, selector?: void, scheduler?: Scheduler): (...args: any[]) => Observable<T>;
static create<T>(callbackFunc: Function, selector?: (...args: any[]) => T, scheduler?: Scheduler): (...args: any[]) => Observable<T>;
/* tslint:enable:max-line-length */

/**
* Converts a callback function to an observable sequence.
* @param {function} callbackFunc Function with a callback as the last
* parameter.
* @param {function} selector A selector which takes the arguments from the
* callback to produce a single item to yield on next.
* @param {Scheduler} [scheduler] The scheduler on which to schedule
* the callbacks.
* @return {function(...params: *): Observable<T>} a function which returns the
* Observable that corresponds to the callback.
* @static true
* @name bindCallback
* @owner Observable
*/
static create<T>(callbackFunc: Function,
selector: Function | void = undefined,
scheduler?: Scheduler): (...args: any[]) => Observable<T> {
Expand Down
14 changes: 14 additions & 0 deletions src/observable/BoundNodeCallbackObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import {tryCatch} from '../util/tryCatch';
import {errorObject} from '../util/errorObject';
import {AsyncSubject} from '../subject/AsyncSubject';

/**
*
*/
export class BoundNodeCallbackObservable<T> extends Observable<T> {
subject: AsyncSubject<T>;

Expand All @@ -20,6 +23,17 @@ export class BoundNodeCallbackObservable<T> extends Observable<T> {
static create<T>(callbackFunc: Function, selector?: void, scheduler?: Scheduler): (...args: any[]) => Observable<T>;
static create<T>(callbackFunc: Function, selector?: (...args: any[]) => T, scheduler?: Scheduler): (...args: any[]) => Observable<T>;
/* tslint:enable:max-line-length */

/**
* Converts a node callback to an Observable.
* @param callbackFunc
* @param selector
* @param scheduler
* @return {function(...params: *): Observable<T>}
* @static true
* @name bindNodeCallback
* @owner Observable
*/
static create<T>(callbackFunc: Function,
selector: Function | void = undefined,
scheduler?: Scheduler): Function {
Expand Down
10 changes: 10 additions & 0 deletions src/observable/DeferObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@ import {Subscriber} from '../Subscriber';
import {tryCatch} from '../util/tryCatch';
import {errorObject} from '../util/errorObject';

/**
*
*/
export class DeferObservable<T> extends Observable<T> {

/**
* @param observableFactory
* @return {DeferObservable}
* @static true
* @name defer
* @owner Observable
*/
static create<T>(observableFactory: () => Observable<T>): Observable<T> {
return new DeferObservable(observableFactory);
}
Expand Down
10 changes: 10 additions & 0 deletions src/observable/EmptyObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@ import {Subscriber} from '../Subscriber';
import {Observable} from '../Observable';
import {Subscription} from '../Subscription';

/**
*
*/
export class EmptyObservable<T> extends Observable<T> {

/**
* @param scheduler
* @return {EmptyObservable<T>}
* @static true
* @name empty
* @owner Observable
*/
static create<T>(scheduler?: Scheduler): Observable<T> {
return new EmptyObservable<T>(scheduler);
}
Expand Down
11 changes: 11 additions & 0 deletions src/observable/ErrorObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@ import {Scheduler} from '../Scheduler';
import {Observable} from '../Observable';
import {Subscription} from '../Subscription';

/**
*
*/
export class ErrorObservable extends Observable<any> {

/**
* @param error
* @param scheduler
* @return {ErrorObservable}
* @static true
* @name throw
* @owner Observable
*/
static create<T>(error: any, scheduler?: Scheduler) {
return new ErrorObservable(error, scheduler);
}
Expand Down
10 changes: 10 additions & 0 deletions src/observable/ForkJoinObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@ import {EmptyObservable} from './EmptyObservable';
import {isPromise} from '../util/isPromise';
import {isArray} from '../util/isArray';

/**
*
*/
export class ForkJoinObservable<T> extends Observable<T> {
constructor(private sources: Array<Observable<any> | Promise<any>>,
private resultSelector?: (...values: Array<any>) => T) {
super();
}

/**
* @param sources
* @return {any}
* @static true
* @name forkJoin
* @owner Observable
*/
static create<T>(...sources: Array<Observable<any> | Promise<any> |
Array<Observable<any>> |
((...values: Array<any>) => any)>): Observable<T> {
Expand Down
12 changes: 12 additions & 0 deletions src/observable/FromEventObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,20 @@ function isEventTarget(sourceObj: any): sourceObj is EventTarget {

export type EventTargetLike = EventTarget | NodeStyleEventEmmitter | JQueryStyleEventEmitter | NodeList | HTMLCollection;

/**
*
*/
export class FromEventObservable<T, R> extends Observable<T> {

/**
* @param sourceObj
* @param eventName
* @param selector
* @return {FromEventObservable}
* @static true
* @name fromEvent
* @owner Observable
*/
static create<T>(sourceObj: EventTargetLike, eventName: string, selector?: (...args: Array<any>) => T): Observable<T> {
return new FromEventObservable(sourceObj, eventName, selector);
}
Expand Down
12 changes: 12 additions & 0 deletions src/observable/FromEventPatternObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@ import {tryCatch} from '../util/tryCatch';
import {errorObject} from '../util/errorObject';
import {Subscriber} from '../Subscriber';

/**
*
*/
export class FromEventPatternObservable<T, R> extends Observable<T> {

/**
* @param addHandler
* @param removeHandler
* @param selector
* @return {FromEventPatternObservable}
* @static true
* @name fromEventPattern
* @owner Observable
*/
static create<T>(addHandler: (handler: Function) => any,
removeHandler: (handler: Function) => void,
selector?: (...args: Array<any>) => T) {
Expand Down
13 changes: 13 additions & 0 deletions src/observable/FromObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,24 @@ import {ObserveOnSubscriber} from '../operator/observeOn';

const isArrayLike = (<T>(x: any): x is ArrayLike<T> => x && typeof x.length === 'number');

/**
*
*/
export class FromObservable<T> extends Observable<T> {
constructor(private ish: Observable<T> | Promise<T> | Iterator<T> | ArrayLike<T>, private scheduler: Scheduler) {
super(null);
}

/**
* @param ish
* @param mapFnOrScheduler
* @param thisArg
* @param lastScheduler
* @return {any}
* @static true
* @name from
* @owner Observable
*/
static create<T>(ish: any, mapFnOrScheduler?: Scheduler | ((x: any, y: number) => T), thisArg?: any, lastScheduler?: Scheduler): Observable<T> {
let scheduler: Scheduler = null;
let mapFn: (x: number, y: any) => T = null;
Expand Down
11 changes: 11 additions & 0 deletions src/observable/IntervalObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@ import {Scheduler} from '../Scheduler';
import {Observable} from '../Observable';
import {asap} from '../scheduler/asap';

/**
*
*/
export class IntervalObservable extends Observable<number> {
/**
* @param period
* @param scheduler
* @return {IntervalObservable}
* @static true
* @name interval
* @owner Observable
*/
static create(period: number = 0, scheduler: Scheduler = asap): Observable<number> {
return new IntervalObservable(period, scheduler);
}
Expand Down
9 changes: 9 additions & 0 deletions src/observable/NeverObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ import {Observable} from '../Observable';
import {Subscriber} from '../Subscriber';
import {noop} from '../util/noop';

/**
*
*/
export class NeverObservable<T> extends Observable<T> {
/**
* @return {NeverObservable<T>}
* @static true
* @name never
* @owner Observable
*/
static create<T>() {
return new NeverObservable<T>();
}
Expand Down
11 changes: 11 additions & 0 deletions src/observable/PromiseObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@ import {Observable} from '../Observable';
import {Subscriber} from '../Subscriber';
import {Subscription} from '../Subscription';

/**
*
*/
export class PromiseObservable<T> extends Observable<T> {

public value: T;

/**
* @param promise
* @param scheduler
* @return {PromiseObservable}
* @static true
* @name fromPromise
* @owner Observable
*/
static create<T>(promise: Promise<T>, scheduler: Scheduler = null): Observable<T> {
return new PromiseObservable(promise, scheduler);
}
Expand Down
Loading

0 comments on commit 7251390

Please sign in to comment.