Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.0k views
in Technique[技术] by (71.8m points)

rxjs 单位时间内只执行一次,这个怎么弄呢?

比如我有组件相互独立,但是都有一个共同的请求,怎么做到在指定时间内只请求一次,比如3秒中内。
不是只请求一次,只是在当前三秒内只执行一次,因为get的数据可能会变


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

请求方法单独写,缓存上次请求时间和上次请求回调数据,收到请求有缓存并在3秒内的直接返回缓存,否则才发送请求。
有使用的组件引入进来。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...