本文整理匯總了TypeScript中rx.Observer類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observer類的具體用法?TypeScript Observer怎麽用?TypeScript Observer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Observer類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: map
export function observerForSocket<T>(map: (t: T) => Buffer,
port: number,
address: string,
socket: dgram.Socket) {
return Rx.Observer.create<T>(
t => {
const buffer = map(t);
socket.send(buffer, 0, buffer.byteLength, port, address);
},
() => socket.close(),
() => socket.close());
}
示例2:
request.end((err, res) => {
if (err) {
obs.onError(err)
} else {
obs.onNext(res)
}
obs.onCompleted()
})
示例3: ap
ap(...args) {
let result = this.step.apply(this, args);
if (this.observer) {
this.observer.onNext(result);
}
return result;
}
示例4: match
s1 = s1.doOnNext((val: string) => {
const action = match(val);
if (action) {
observer.onNext(action);
}
});
示例5:
output.on('action', (obj: Object) => {
observer.onNext(obj);
});
示例6:
child.on('exit', () => {
observer.onCompleted();
});