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


TypeScript Observable.bindCallback方法代碼示例

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


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

示例1: login

 login(): Observable<boolean> {
   Observable.bindCallback(
     PDK.login.bind(PDK, {scope: 'read_public, write_public, read_relationships'}),
     (response: any) => response.session)()
     .subscribe(() => this.broadcastLoggedIn());
   return this.loggedIn$;
 }
開發者ID:cyk,項目名稱:pin-head,代碼行數:7,代碼來源:pinterest.service.ts

示例2: repin

  repin(pin: any, board: any): Observable<Object> {
    let url = board.url.split('/').slice(-3, -1).join('/');

    let data = {
      board: url,
      note: pin.note,
      link: pin.link,
      image_url: pin.image.original.url
    };
    return Observable.bindCallback(
      PDK.request.bind(PDK, '/pins/', 'POST', data),
      (response: any) => response.data
    )();
  }
開發者ID:cyk,項目名稱:pin-head,代碼行數:14,代碼來源:pinterest.service.ts

示例3: performAjaxRequest

 private performAjaxRequest(url, requestData): Observable<any> {
     return Observable.bindCallback((onSuccess: any) => {
         $.ajax({
             url: url,
             type: 'POST',
             data: requestData,
             cache: false,
             contentType: false,
             processData: false,
             success: (data, textStatus, jqXHR) => onSuccess(JSON.parse(data)),
             error: function(jqXHR, textStatus, errorThrown)
             {
                 console.log('ERRORS: ' + textStatus);
                 onSuccess(textStatus);
             }
         });
     })();
 }
開發者ID:Le0Michine,項目名稱:Messanger,代碼行數:18,代碼來源:file-upload.service.ts

示例4: speakObservable

            const capabilities = {
                type: 'ClientCapabilities',
                requiresBotState: true,
                supportsTts: true,
                supportsListening: true
                // Todo: consider implementing acknowledgesTts: true
            };
            (activity as any).entities = (activity as any).entities == null ? [capabilities] :  [...(activity as any).entities, capabilities];
        }

        return state.connection.botConnection.postActivity(activity)
        .map(id => ({ type: 'Send_Message_Succeed', clientActivityId, id } as HistoryAction))
        .catch(error => Observable.of({ type: 'Send_Message_Fail', clientActivityId } as HistoryAction));
    });

const speakObservable = Observable.bindCallback<string, string, {}, {}>(Speech.SpeechSynthesizer.speak);

const speakSSMLEpic: Epic<ChatActions, ChatState> = (action$, store) =>
    action$.ofType('Speak_SSML')
    .filter(action => action.ssml )
    .mergeMap(action => {

        let onSpeakingStarted = null;
        let onSpeakingFinished = () => nullAction;
        if (action.autoListenAfterSpeak) {
            onSpeakingStarted = () => Speech.SpeechRecognizer.warmup() ;
            onSpeakingFinished = () => ({ type: 'Listening_Starting' } as ShellAction);
        }

        const call$ = speakObservable(action.ssml, action.locale, onSpeakingStarted);
        return call$.map(onSpeakingFinished)
開發者ID:alfumit,項目名稱:BotFramework-WebChat,代碼行數:31,代碼來源:Store.ts

示例5: pins

 pins(board: any): Observable<Object> {
   return Observable.bindCallback(
     PDK.request.bind(PDK, `/boards/${board.id}/pins/`, {fields: 'id,note,link,image'}),
     (response: any) => response.data
   )().concatAll();
 }
開發者ID:cyk,項目名稱:pin-head,代碼行數:6,代碼來源:pinterest.service.ts

示例6: followedBoards

 followedBoards(): Observable<any[]> {
   return Observable.bindCallback(
     PDK.me.bind(PDK, 'following/boards', {fields:'id,description,name,image'}),
     (response: any) => response.data
   )();
 }
開發者ID:cyk,項目名稱:pin-head,代碼行數:6,代碼來源:pinterest.service.ts

示例7: logout

 logout(): Observable<boolean> {
   Observable.bindCallback(PDK.logout.bind(PDK))()
   .subscribe(() => this.broadcastLoggedIn());
   return this.loggedIn$;
 }
開發者ID:cyk,項目名稱:pin-head,代碼行數:5,代碼來源:pinterest.service.ts

示例8: snap

 snap(): Observable<string> {
   return Observable.bindCallback(
     Webcam.snap.bind(Webcam),
     (dataUri: string) => dataUri.replace('data:image/jpeg;base64,', '')
   )();
 }
開發者ID:cyk,項目名稱:pin-head,代碼行數:6,代碼來源:webcam.service.ts

示例9:

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);
});
開發者ID:WhateverSkynet,項目名稱:nodebb-plugin-moonlight,代碼行數:31,代碼來源:helpers.ts


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