///
/**
* ngTable: Table + Angular JS
*
* @author Vitalii Savchuk
* @url https://github.com/esvit/ng-table/
* @license New BSD License
*/
import * as ng1 from 'angular';
import { IScope } from 'angular';
import { DataResult } from './data';
import { IPageButton } from './paging';
import { NgTableParams } from './ngTableParams';
/**
* Alias for the types that can be used to filter events
*/
export declare type EventSelector = NgTableParams | IEventSelectorFunc;
/**
* Signature of the event hander that is registered to receive the *afterCreated* event
*/
export interface IAfterCreatedListener {
(publisher: NgTableParams): any;
}
/**
* Signature of the event hander that is registered to receive the *afterReloadData* event
*/
export interface IAfterReloadDataListener {
(publisher: NgTableParams, newData: DataResult[], oldData: DataResult[]): any;
}
/**
* Signature of the event hander that is registered to receive the *datasetChanged* event
*/
export interface IDatasetChangedListener {
(publisher: NgTableParams, newDataset: T[], oldDataset: T[]): any;
}
/**
* Signature of the function used to filter the events to only specific instances of
* {@link NgTableParams}
*/
export interface IEventSelectorFunc {
(publisher: NgTableParams): boolean;
}
/**
* Signature of the event hander that is registered to receive the *pagesChanged* event
*/
export interface IPagesChangedListener {
(publisher: NgTableParams, newPages: IPageButton[], oldPages: IPageButton[]): any;
}
/**
* Signature of the event hander that is registered to receive the *afterDataFiltered* event
*/
export interface IAfterDataFilteredListener {
(publisher: NgTableParams, newData: DataResult[]): any;
}
/**
* Signature of the event hander that is registered to receive the *afterDataSorted* event
*/
export interface IAfterDataSortedListener {
(publisher: NgTableParams, newData: DataResult[]): any;
}
/**
* Signature of the function used to explicitly unregister an event handler so that it stops
* receiving notifications
*/
export interface IUnregistrationFunc {
(): void;
}
/**
* Strongly typed pub/sub for {@link NgTableParams}
*
* Supported events:
*
* * afterCreated - raised when a new instance of {@link NgTableParams} has finished being constructed
* * afterReloadData - raised when the {@link NgTableParams} `reload` method has finished loading new data
* * datasetChanged - raised when {@link ISettings} `dataset` receives a new data array
* * pagesChanged - raised when a new pages array has been generated
*/
export interface NgTableEventsChannel {
/**
* Subscribe to receive notification whenever a new `NgTableParams` instance has finished being constructed.
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a
* `scope` to have angular automatically unregister the listener when the `scope` is destroyed.
*
* @param listener the function that will be called when the event fires
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
* @param eventFilter a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onAfterCreated(listener: IAfterCreatedListener, scope: IScope, eventFilter?: IEventSelectorFunc): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever a new `NgTableParams` instance has finished being constructed.
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
*
* @param listener the function that will be called when the event fires
* @param eventFilter a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onAfterCreated(listener: IAfterCreatedListener, eventFilter?: IEventSelectorFunc): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever the `reload` method of an `NgTableParams` instance has successfully executed
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a
* `scope` to have angular automatically unregister the listener when the `scope` is destroyed.
*
* @param listener the function that will be called when the event fires
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onAfterReloadData(listener: IAfterReloadDataListener, scope: IScope, eventFilter?: EventSelector): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever the `reload` method of an `NgTableParams` instance has successfully executed
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
*
* @param listener the function that will be called when the event fires
* @param eventFilter a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onAfterReloadData(listener: IAfterReloadDataListener, eventFilter?: EventSelector): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever a new data rows *array* is supplied as a `settings` value to a `NgTableParams` instance.
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a
* `scope` to have angular automatically unregister the listener when the `scope` is destroyed.
*
* @param listener the function that will be called when the event fires
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onDatasetChanged(listener: IDatasetChangedListener, scope: IScope, eventFilter?: EventSelector): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever a new data rows *array* is supplied as a `settings` value to a `NgTableParams` instance.
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
*
* @param listener the function that will be called when the event fires
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onDatasetChanged(listener: IDatasetChangedListener, eventFilter?: EventSelector): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever the paging buttons for an `NgTableParams` instance change
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a
* `scope` to have angular automatically unregister the listener when the `scope` is destroyed.
*
* @param listener the function that will be called when the event fires
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onPagesChanged(listener: IPagesChangedListener, scope: IScope, eventFilter?: EventSelector): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever the paging buttons for an `NgTableParams` instance change
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
*
* @param listener the function that will be called when the event fires
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onPagesChanged(listener: IPagesChangedListener, eventFilter?: EventSelector): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever a `ngTableDefaultGetData` instance filters data
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
*
* @param listener the function that will be called when the event fires
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
* @param eventFilter either the specific `IDefaultGetData` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onAfterDataFiltered(listener: IAfterDataFilteredListener, scope: IScope, eventFilter?: EventSelector): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever a `ngTableDefaultGetData` instance filters data
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
*
* @param listener the function that will be called when the event fires
* @param eventFilter either the specific `IDefaultGetData` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onAfterDataFiltered(listener: IAfterDataFilteredListener, eventFilter?: EventSelector): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever a `ngTableDefaultGetData` instance orders data
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
*
* @param listener the function that will be called when the event fires
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
* @param eventFilter either the specific `IDefaultGetData` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onAfterDataSorted(listener: IAfterDataSortedListener, scope: IScope, eventFilter?: EventSelector): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever a `ngTableDefaultGetData` instance orders data
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
*
* @param listener the function that will be called when the event fires
* @param eventFilter either the specific `IDefaultGetData` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onAfterDataSorted(listener: IAfterDataSortedListener, eventFilter?: EventSelector): IUnregistrationFunc;
publishAfterCreated(publisher: NgTableParams): void;
publishAfterReloadData(publisher: NgTableParams, newData: T[], oldData: T[]): void;
publishDatasetChanged(publisher: NgTableParams, newDataset: T[], oldDataset: T[]): void;
publishPagesChanged(publisher: NgTableParams, newPages: IPageButton[], oldPages: IPageButton[]): void;
publishAfterDataFiltered(publisher: NgTableParams, newData: T[]): void;
publishAfterDataSorted(params: NgTableParams, newData: T[]): void;
}
export declare class NgTableEventsChannel {
private $rootScope;
static $inject: string[];
constructor($rootScope: ng1.IRootScopeService);
private addTableParamsEvent(eventName, target);
private createPublishEventFn(eventName);
private createEventSubscriptionFn(eventName);
}