pip-services3-commons-node
Version: 
Portable abstractions and patterns for Pip.Services in Node.js
30 lines (29 loc) • 818 B
TypeScript
/** @module run */
/**
 * Interface for components that should clean their state.
 *
 * Cleaning state most often is used during testing.
 * But there may be situations when it can be done in production.
 *
 * @see [[Cleaner]]
 *
 * ### Example ###
 *
 *     class MyObjectWithState implements ICleanable {
 *         private _state: any = {};
 *         ...
 *         public clear(correlationId: string): void {
 *             this._state = {};
 *         }
 *     }
 *
 */
export interface ICleanable {
    /**
     * Clears component state.
     *
     * @param correlationId 	(optional) transaction id to trace execution through call chain.
     * @param callback 			callback function that receives error or null no errors occured.
     */
    clear(correlationId: string, callback?: (err: any) => void): void;
}