diff --git a/src/core/pipe.js b/src/core/pipe.js index d7c4139..2835a50 100644 --- a/src/core/pipe.js +++ b/src/core/pipe.js @@ -1,6 +1,6 @@ import EventEmitter from 'events'; import {MIDDLEWARE_DIRECTION_UPWARD} from './middleware'; -import {PRESET_INIT, PRESET_FAILED} from '../presets/defs'; +import {PRESET_FAILED} from '../presets/defs'; export class Pipe extends EventEmitter { @@ -49,8 +49,6 @@ export class Pipe extends EventEmitter { } this._upstream_middlewares = middlewares; this._downstream_middlewares = [].concat(middlewares).reverse(); - // initial broadcast - this.broadcast('pipe', {type: PRESET_INIT}); } getMiddlewares(direction = MIDDLEWARE_DIRECTION_UPWARD) { diff --git a/src/presets/defs.js b/src/presets/defs.js index d8fcc36..3255656 100644 --- a/src/presets/defs.js +++ b/src/presets/defs.js @@ -2,8 +2,6 @@ // - pushed by relay -export const PRESET_INIT = '@action:preset_init'; - /** * { * type: CONNECTION_CREATED, @@ -70,15 +68,30 @@ export const PRESET_PAUSE_SEND = '@action:preset_pause_send'; export const PRESET_RESUME_RECV = '@action:preset_resume_recv'; export const PRESET_RESUME_SEND = '@action:preset_resume_send'; +/** + * + * @lifecycle + * [static checkParams() -> static onInit()] -> constructor() -> ... -> onDestroy() + * Only call once + */ export class IPreset { /** * check params passed to the preset, if any errors, should throw directly + * @param params */ static checkParams(params) { } + /** + * you can make some cache in this function + * @param params + */ + static onInit(params) { + + } + // callbacks /**