当前位置:网站首页>Introduction to the implementation principle of rxjs observable filter operator
Introduction to the implementation principle of rxjs observable filter operator
2022-07-03 11:50:00 【InfoQ】
import { fromEvent, interval, MonoTypeOperatorFunction } from 'rxjs';
import { filter } from 'rxjs/operators';
function filterKey(key) {
console.log('input: ', key);
const result: MonoTypeOperatorFunction<KeyboardEvent> = filter(
(event: KeyboardEvent) => {
console.log('input event: ', event);
return event.key === key;
}
);
console.log('result: ', result);
return result;
}
fromEvent(document, 'keyup')
.pipe(filterKey('Enter'))
.subscribe(
(data) => console.log(data) // KeyboardEvent
);












setupSubscription
export declare function filter<T>(predicate: (value: T, index: number) => boolean, thisArg?: any): MonoTypeOperatorFunction<T>;



边栏推荐
猜你喜欢

STL教程10-容器共性和使用场景

vulnhub之GeminiInc v2

Kibana - installation and configuration of kibana

vulnhub之tomato(西红柿)

XML (DTD, XML parsing, XML modeling)

STL Tutorial 9 deep copy and shallow copy of container elements

Momentum of vulnhub

The tutor put forward 20 pieces of advice to help graduate students successfully complete their studies: first, don't plan to take a vacation

银泰百货点燃城市“夜经济”

Event preview | the live broadcast industry "rolled in" to drive new data growth points with product power
随机推荐
vulnhub之momentum
Ripper of vulnhub
Nestjs configuration service, configuring cookies and sessions
STL tutorial 10 container commonalities and usage scenarios
Vulnhub's cereal
Cacti监控Redis实现过程
Experience container in libvirt
Software testing weekly (issue 78): the more confident you are about the future, the more patient you are about the present.
AOSP ~ NTP ( 网络时间协议 )
The R language uses the hist function in the native package (basic import package, graphics) to visualize the histogram plot
Uniapp implementation Click to load more
R language uses grid of gridextra package The array function combines multiple visual images of the ggplot2 package horizontally, and the ncol parameter defines the number of columns of the combined g
Kubernetes 三打探针及探针方式
How to mix embedded MCU, arm and DSP?
外插散点数据
Test classification in openstack
Concurrent programming - singleton
vulnhub之raven2
vulnhub之cereal
2022年湖南工学院ACM集训第二次周测题解