當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Observable.fromNodeCallback方法代碼示例

本文整理匯總了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(() => {
開發者ID:dschenkelman,項目名稱:rx-udp,代碼行數:7,代碼來源:index.tests.ts

示例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(() => { });
    }
  }
},
開發者ID:aelbore,項目名稱:loopback-model-binder,代碼行數:11,代碼來源:model-loader-utils.ts

示例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);
}
開發者ID:b-cuts,項目名稱:browser-sync-core,代碼行數:21,代碼來源:online.ts

示例4: readDir

function readDir(directory): Rx.Observable<string[]> {
    const readdir = Rx.Observable.fromNodeCallback<string[]>(fs.readdir);
    return readdir(directory);
}
開發者ID:Jason-Rev,項目名稱:json-schema-to-typescript,代碼行數:4,代碼來源:jsonSchemaTsCodegen.ts

示例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');
開發者ID:b-cuts,項目名稱:browser-sync-core,代碼行數:30,代碼來源:ports.ts


注:本文中的rx.Observable.fromNodeCallback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。