本文整理汇总了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$;
}
示例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
)();
}
示例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);
}
});
})();
}
示例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)
示例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();
}
示例6: followedBoards
followedBoards(): Observable<any[]> {
return Observable.bindCallback(
PDK.me.bind(PDK, 'following/boards', {fields:'id,description,name,image'}),
(response: any) => response.data
)();
}
示例7: logout
logout(): Observable<boolean> {
Observable.bindCallback(PDK.logout.bind(PDK))()
.subscribe(() => this.broadcastLoggedIn());
return this.loggedIn$;
}
示例8: snap
snap(): Observable<string> {
return Observable.bindCallback(
Webcam.snap.bind(Webcam),
(dataUri: string) => dataUri.replace('data:image/jpeg;base64,', '')
)();
}
示例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);
});