com.phloxui
Version:
PhloxUI Ng2+ Framework
66 lines (65 loc) • 3.8 kB
TypeScript
/**
* <p style="text-indent: 2em;">
* A <code>ng</code> service interface mainly handles <code>application</code>'s <code>background process</code> executions.
* Despite the <code>ng</code> framework provides you an <code>asynchronous</code> execution mechanism via <code>Promise</code>
* or <code>Observer</code> already, this service aims to make all those <code>asynchronous</code> executions easily monitorable
* by the user. For example, if your <code>application</code> needs to execute multiple <code>asynchronous</code> user's tasks
* such as saving multiple documents to the backend server at the same time, by using this service, it will keep record of
* those processes and give you the information about which one is running or is complete at any time.
* </p>
*
* @author shiorin, tee4cute
* @see [[BackgroundProcessManager]]
*/
export interface IBackgroundProcessManager {
/**
* <p style="text-indent: 1em;">
* Execute a new background process which will <code>perform</code> the given <code><b>processFunc</b></code>.
* </p>
*
* @param processFunc A <code>function</code> which will be performed asynchronously.
* @param option A configuration object. This depends on each implementation of this interface. But, at least, it should contain the following
* properties:<br/>
* <code>
* {
* "type": "string",
* "name": "string"
* }
* </code>
*
* @return A <code>Promise</code> which will be <code>resolved</code> when the execution is done and its <code>result</code> is the value
* returned from the given <code><b>processFunc</b></code>. If the given <code><b>processFunc</b></code> returns a <code>Promise</code>,
* this method will return that <code>Promise</code> directly.
*
*/
execute(processFunc: Function, option?: any): Promise<any>;
/**
* <p style="text-indent: 1em;">
* Get the running processes count by the given <code><b>typeName</b></code> and <code><b>name</b></code>. If you want to
* count all running processes in the system, just pass <code>null</code> into all parameters. The returning value of this method must be
* the same as <code>array's length</code> returned from [[getRunningProcesses]] method.
* </p>
*
* @param typeName A process <code>type name</code>. Passing <code>null</code> means no filter or including all <code>type name</code>s.
* @param name A process <code>name</code>. Passing <code>null</code> means no filter or including all process <code>name</code>s.
*
* @return A number of running processes according to the given <code><b>typeName</b></code> and <code><b>name</b></code>.
* This method will return <code>0</code> if no matching running process found.
*
*/
getRunningProcessesCount(typeName: string, name: string): number;
/**
* <p style="text-indent: 1em;">
* Get <code>model</code>s of running processes by the given <code><b>typeName</b></code> and <code><b>name</b></code>. If you want to
* get all running process <code>model</code>s in the system, just pass <code>null</code> into all parameters.
* </p>
*
* @param typeName A process <code>type name</code>. Passing <code>null</code> means no filter or including all <code>type name</code>s.
* @param name A process <code>name</code>. Passing <code>null</code> means no filter or including all process <code>name</code>s.
*
* @return An array of running process <code>model</code>s according to the given <code><b>typeName</b></code> and <code><b>name</b></code>.
* This method will return an <code>empty array</code> if no matching running process found.
*
*/
getRunningProcesses(typeName: string, name: string): any[];
}