本文整理汇总了TypeScript中flux.Dispatcher.register方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Dispatcher.register方法的具体用法?TypeScript Dispatcher.register怎么用?TypeScript Dispatcher.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flux.Dispatcher
的用法示例。
在下文中一共展示了Dispatcher.register方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: new
static register<T>(actionToRegister: { new(...args: any[]): T; }, callback: (payload: T) => void) {
return dispatcher.register((action) => {
if (action instanceof (actionToRegister as any)) {
callback(action as any);
}
});
}
示例2: constructor
constructor() {
super();
this.dispatcher = new Dispatcher<ActionType>();
this.size = {
lines: 0,
cols: 0,
width: 0,
height: 0,
};
this.font_attr = {
fg: 'white',
bg: 'black',
bold: false,
italic: false,
underline: false,
undercurl: false,
draw_width: 1,
draw_height: 1,
width: 1,
height: 1,
specified_px: 1,
face: 'monospace',
};
this.cursor = {
line: 0,
col: 0,
};
this.mode = 'normal';
this.busy = false;
this.mouse_enabled = true;
this.dragging = null;
this.title = 'Neovim'; // TODO: This should be set by API. I must implement it after making store non-singleton
this.icon_path = '';
this.wheel_scrolling = new ScreenWheel(this);
this.scroll_region = {
left: 0,
right: 0,
top: 0,
bottom: 0,
};
this.focused = true;
this.line_height = 1.2;
this.alt_key_disabled = false;
this.cursor_draw_delay = 10;
this.blink_cursor = true;
this.cursor_blink_interval = 1000;
this.dispatch_token = this.dispatcher.register(this.receiveAction.bind(this));
}
示例3: handleServerAction
}
let dispatcherIsDispatching: boolean;
let dispatcherToken: string;
const actionPayload = {
data: {},
source: ActionSource.Server,
type: ActionType.Create
};
/**
* Basic dispatcher
*/
const basicDispatcher: Dispatcher<Action> = new Dispatcher<Action>();
dispatcherToken = basicDispatcher.register(dispatcherCallback);
basicDispatcher.unregister(dispatcherToken);
basicDispatcher.waitFor([dispatcherToken]);
basicDispatcher.dispatch(actionPayload);
dispatcherIsDispatching = basicDispatcher.isDispatching();
/**
* Custom dispatcher
*/
class CustomDispatcher extends Dispatcher<Action> {
// Dispatch an action with server as source
handleServerAction(type: ActionType, data: {}) {
this.dispatch({
source: ActionSource.Server,
type,
data