core,presets: remove PRESET_INIT, add static onInit() to IPreset
This commit is contained in:
parent
4db9bbb3b9
commit
c52ebbae9b
@ -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) {
|
||||
|
@ -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
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user