当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Dispatcher.register方法代码示例

本文整理汇总了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);
         }
     });
 }
开发者ID:kgosse,项目名称:mastering_typescript,代码行数:7,代码来源:app-dispatcher.ts

示例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));
 }
开发者ID:ChrisPenner,项目名称:neovim-component,代码行数:48,代码来源:store.ts

示例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
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:31,代码来源:Flux.ts


注:本文中的flux.Dispatcher.register方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。