import './observable'; import { Observable } from 'rxjs/Observable'; /** * Observer for next value from observable (used by subscribe() function) * * @export * @interface ActionObserver */ export interface ActionObserver { (state: any, action: Action): Observable; } /** * Observer for an error from observable (used by subscribe() function) * * @export * @interface ErrorObserver */ export interface ErrorObserver { (error: any): void; } /** * Defines an action which an be extended to implement custom actions for a reflux application * * @example * * // Create your own action class * class PageSwitchAction extends Action { * constructor(public pageId: string) { * super() * } * } * * // Subscribe to your action * new PageSwitchAction(undefined).subscribe((state: State, action: PageSwitchAction): Observable => { * return Observable.create((observer: Observer) => { * observer.next(updatedState) * observer.complete() * }).share() * }, this) * * // Dispatch your action * new PageSwitchAction('page1').dispatch() * * @export * @class Action */ export declare class Action { /** * The last action occurred * * @readonly * @static * * @memberOf Action */ static readonly lastAction: Action; /** * Returns identity of this class * * @readonly * @type {string} */ readonly identity: string; /** * Subscribe to this action. actionObserver will be called when 'dispatch()' is invoked * * @param {ActionObserver} actionObserver The function that process the action * @param {*} context Context binding * @returns {Action} */ subscribe(actionObserver: ActionObserver, context: any): Action; /** * Dispatch this action. Returns an observable which will be completed when all action subscribers * complete it's processing * * @returns {Promise} */ dispatch(): Promise; }