本文整理汇总了TypeScript中rxjs.fromEventPattern函数的典型用法代码示例。如果您正苦于以下问题:TypeScript fromEventPattern函数的具体用法?TypeScript fromEventPattern怎么用?TypeScript fromEventPattern使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fromEventPattern函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should send errors in the selector down the error path', (done: MochaDone) => {
let target: any;
const trigger = (value: any) => {
if (target) {
target(value);
}
};
const addHandler = (handler: any) => {
target = handler;
};
const removeHandler = (handler: any) => {
target = null;
};
const selector = (x: any) => {
throw 'bad';
};
fromEventPattern(addHandler, removeHandler, selector)
.subscribe((x: any) => {
done(new Error('should not be called'));
}, (err: any) => {
expect(err).to.equal('bad');
done();
}, () => {
done(new Error('should not be called'));
});
trigger('test');
});
开发者ID:DallanQ,项目名称:rxjs,代码行数:30,代码来源:fromEventPattern-spec.ts
示例2: addHandler
('should create an observable from the handler API', () => {
function addHandler(h: any) {
timer(50, 20, rxTestScheduler).pipe(
mapTo('ev'),
take(2),
concat(NEVER)
).subscribe(h);
}
const e1 = fromEventPattern(addHandler);
const expected = '-----x-x---';
expectObservable(e1).toBe(expected, {x: 'ev'});
});
开发者ID:DallanQ,项目名称:rxjs,代码行数:12,代码来源:fromEventPattern-spec.ts
示例3: fromEventPattern
observable1 = constructorZone1.run(() => {
return fromEventPattern(
(handler: any) => {
expect(Zone.current.name).toEqual(constructorZone1.name);
button.addEventListener('click', handler);
log.push('addListener');
},
(handler: any) => {
expect(Zone.current.name).toEqual(constructorZone1.name);
button.removeEventListener('click', handler);
document.body.removeChild(button);
log.push('removeListener');
});
});
开发者ID:angular,项目名称:zone.js,代码行数:14,代码来源:rxjs.fromEvent.spec.ts
示例4: addHandler
export function fromHistory<LocationState>(
history: History
): Observable<[Location<LocationState>, Action]> {
let unregisterCallback: UnregisterCallback;
function addHandler(handler: LocationListener): void {
unregisterCallback = history.listen(handler);
handler(history.location, history.action);
}
function removeHandler(): void {
if (unregisterCallback) {
unregisterCallback();
}
}
return fromEventPattern<[Location<LocationState>, Action]>(
addHandler,
removeHandler
);
}
开发者ID:evertbouw,项目名称:rx-history,代码行数:21,代码来源:fromHistory.ts
注:本文中的rxjs.fromEventPattern函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论