本文整理汇总了TypeScript中rxjs/Observable.Observable.bindNodeCallback方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Observable.bindNodeCallback方法的具体用法?TypeScript Observable.bindNodeCallback怎么用?TypeScript Observable.bindNodeCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxjs/Observable.Observable
的用法示例。
在下文中一共展示了Observable.bindNodeCallback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
import { Observable } from 'rxjs/Observable';
// Webpack doesn't bundle correctly without this. TODO: figure out why & fix.
import 'rxjs/add/observable/bindNodeCallback';
import 'rxjs/add/observable/bindCallback';
export interface SocketOptions {
event: string;
payload?: any;
}
const emit = Observable.bindNodeCallback((options: SocketOptions, callback: (err: Error, data: any) => void) => {
window.socket.emit(options.event, options.payload || {}, callback);
});
const on = Observable.bindCallback((options: SocketOptions, callback: (data: any) => void) => {
window.socket.on(options.event, callback);
});
export const Socket = {
emit,
on
};
export interface HttpOptions {
url: string;
payload?: any;
}
const get = Observable.bindNodeCallback((url: string, callback: (data: any) => void) => {
window.ajaxify.loadData(url, callback);
});