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


TypeScript Observable.bindNodeCallback方法代碼示例

本文整理匯總了TypeScript中rxjs.Observable.bindNodeCallback方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observable.bindNodeCallback方法的具體用法?TypeScript Observable.bindNodeCallback怎麽用?TypeScript Observable.bindNodeCallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rxjs.Observable的用法示例。


在下文中一共展示了Observable.bindNodeCallback方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

 */
import * as _ from 'lodash';
import { Observable, Subscription } from 'rxjs';
import { CommandType, Definition, IAtomNavigation, IDefinitionProvider, IDefinitionService, Reference, navigationHasRange } from 'atom-languageservices';
import { alias, injectable } from 'atom-languageservices/decorators';
import { readFile } from 'fs';
import { ProviderServiceBase } from './_ProviderServiceBase';
import { atomConfig } from '../decorators';
import { AtomCommands } from './AtomCommands';
import { AtomNavigation } from './AtomNavigation';
import { AtomTextEditorSource } from './AtomTextEditorSource';
import { CommandsService } from './CommandsService';
import { ReferenceView } from './views/ReferenceView';
type Location = IAtomNavigation.Location;

const readFile$ = Observable.bindNodeCallback(readFile);
@injectable
@alias(IDefinitionService)
@atomConfig({
    default: true,
    description: 'Adds support for navigate to definition or definitions'
})
export class DefinitionService
    extends ProviderServiceBase<IDefinitionProvider, Definition.IRequest, Observable<Location[]>, Observable<Location[]>>
    implements IDefinitionService {
    private _navigation: AtomNavigation;
    private _commands: CommandsService;
    private _atomCommands: AtomCommands;
    private _source: AtomTextEditorSource;

    constructor(navigation: AtomNavigation, commands: CommandsService, atomCommands: AtomCommands, source: AtomTextEditorSource) {
開發者ID:OmniSharp,項目名稱:atom-languageclient,代碼行數:31,代碼來源:DefinitionService.ts

示例2: getPluginPath

import { exec } from 'child_process';
import * as fs from 'fs';
import { join } from 'path';
import { Observable } from 'rxjs';
import { ILogger, IOmnisharpPlugin } from '../enums';
import { createObservable } from '../operators/create';
import { RuntimeContext } from './runtime';

const bootstrappedPlugins = new Map<string, string>();
const exists = Observable.bindCallback(fs.exists);
const readFile: (file: string) => Observable<any> = Observable.bindNodeCallback(fs.readFile);
// tslint:disable-next-line:no-var-requires no-require-imports
const md5: (value: any) => string = require('md5');

// tslint:disable-next-line:export-name
export function getPluginPath(solutionLocation: string, ctx: RuntimeContext, requestedPlugins: IOmnisharpPlugin[], logger: ILogger) {
    const plugins: any[] = [];
    const hashStrings: any[] = [];
    let hash: string;
    requestedPlugins.forEach(plugin => {
        plugins.push(plugin);
    });

    return createObservable<string>(observer => {
        logger.log('Bootstrapping ' + solutionLocation);
        // Include the plugins defined in omnisharp.json, they could have changed.
        exists(join(solutionLocation, 'omnisharp.json'))
            .filter(x => !!x)
            .flatMap(x => readFile(join(solutionLocation, 'omnisharp.json')))
            .map(x => JSON.parse(x.toString()))
            .do({
開發者ID:OmniSharp,項目名稱:omnisharp-node-client,代碼行數:31,代碼來源:plugin.ts

示例3: return

 return (collection: Collection): Observable<void> => {
   let cb: Function = collection.createIndex.bind(collection);
   let opts: Object = { unique: true };
   return Observable.bindNodeCallback<void>(cb)(field, opts);
 }
開發者ID:delta62,項目名稱:chore-api,代碼行數:5,代碼來源:db.ts

示例4: writeFileStreamCB

    Observable.create(function (observer) {
        function writeFileStreamCB(e, file) {
            if (e) return observer.error(e);

            observer.next(merge(
                getFilenameMetaData(path || ''),
                {file}
            ));
            observer.complete();
        }

        fs.writeFile(path, data, writeFileStreamCB);
    });


const xmlToObservable = Observable.bindNodeCallback(parseString);

function isFeedItem(x:OutlineFeedParent|OutlineFolderParent):x is OutlineFeedParent {
    return compose(
        lt(0),
        length,
        path(['$', 'xmlUrl'])
    )(x)
}

const getOutline:(x:OutlineFolderParent) => Array<OutlineFolderParent> = prop('outline');


const sortableURI:(x:string) => string = (x = '')=> {
    const u = new URI(x);
    return u.hostname()
開發者ID:r-k-b,項目名稱:newsblur-feed-info,代碼行數:31,代碼來源:index.ts

示例5: connect

 connect(uri: string): Observable<MongoDb> {
   let client = new MongoClient();
   let cb: Function = client.connect.bind(client);
   return Observable.bindNodeCallback<MongoDb>(cb)(uri);
 }
開發者ID:delta62,項目名稱:chore-api,代碼行數:5,代碼來源:db.ts

示例6:

import {Observable} from 'rxjs';
import {writeFile as writeFile_} from 'fs';

export const writeFile = Observable.bindNodeCallback(writeFile_);
開發者ID:CurlyHeir,項目名稱:blow-gateway,代碼行數:4,代碼來源:fs.ts


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