本文整理匯總了TypeScript中rx.Observable.fromNodeCallback方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observable.fromNodeCallback方法的具體用法?TypeScript Observable.fromNodeCallback怎麽用?TypeScript Observable.fromNodeCallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rx.Observable
的用法示例。
在下文中一共展示了Observable.fromNodeCallback方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Buffer
Rx.Observable.from(valuesSent).flatMap(value => {
return Rx.Observable.fromNodeCallback<string, number>(
(message: string, callback: (err: Error, result: number) => void) => {
const buffer = new Buffer(message, "utf8");
client.send(buffer, 0, buffer.byteLength, SERVER_PORT, SERVER_HOST, callback);
})(value);
}).subscribeOnCompleted(() => {
示例2: ReadGlob
let SeedData = (seed, model, collection, dataSource) => {
if (seed.isSeed) {
let files = ReadGlob(PathJoin(seed.rootDir, `./${toSpinalCase(collection)}.js`));
if (files) {
let RxNodeCallBack: any = Rx.Observable.fromNodeCallback(seeFile);
Rx.Observable
.for(files, file => RxNodeCallBack(file, model, dataSource))
.subscribe(() => { });
}
}
},
示例3: require
'use strict';
const Rx = require('rx');
const just = Rx.Observable.just;
const online = Rx.Observable.fromNodeCallback(require('dns').resolve);
import utils from './utils';
/**
* @param {Map} options
* @returns {Observable}
*/
export function isOnline (options) {
const opt = options.get('online');
if (utils.isUndefined(opt)) {
return online('www.google.com')
.flatMap(just(true))
.catch(just(false));
}
return just(opt);
}
示例4: readDir
function readDir(directory): Rx.Observable<string[]> {
const readdir = Rx.Observable.fromNodeCallback<string[]>(fs.readdir);
return readdir(directory);
}
示例5: require
'use strict';
const Rx = require('rx');
const just = Rx.Observable.just;
const zip = Rx.Observable.zip;
const debug = require('debug')('bs:ports');
const findPort = Rx.Observable.fromNodeCallback(require('portscanner').findAPortNotInUse);
function getPort (start, strict, name) {
debug(`> trying ${start} for ${name}`);
return findPort(start, undefined, {host: 'localhost', timeout: 1000})
.flatMap(function (x) {
debug(`+ success ${x} for ${name}`);
if (strict && start !== x) {
return Rx.Observable.throw('Strict Mode: Port ' + start + ' not available');
}
return just(x);
});
}
export function getPorts(options) {
const strict = options.get('strict');
const port1 = options.get('port');