💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] # 介绍 # 核心概念 ## Observable (可观察的物件) ## Observer (观察者) ## Subscription (订阅) ## Operators (操作符) ## Subject (主题) # Rxjs 运行方式 ## 建立可观察事物 Observable ```js const clicks$ = rxjs.fromEvent(document, 'click'); ``` ## 进行操作符操作 ```js const { filter } = rxjs.operators; clicks$ = clicks$.pipe(filter(d => d.clientX < 1000)) // 多个操作连续操作 clicks$ = clicks$.pipe( filter(d => d.clientX < 1000), take(4) ) ``` ## 建立订阅(订阅 Observable 事物并自动建立观察者) ```js const subs$ = clicks$.subscribe({next: (d) => console.log(d) }); // 简写形式: const subs$ = clicks$.subscribe(console.log); ``` ## 取消订阅(Subscription) ```js subs$.unsubscribe(); ``` # 参考 [一小时入门RxJS,中文教学放心适用,讲解非常棒](https://www.bilibili.com/video/BV1Mt4y127An?from=search&seid=15910065297616585878) https://www.youtube.com/watch?v=BA1vSZwzkK8 官网:https://rxjs-dev.firebaseapp.com/ 图解rxjs: https://reactive.how/ [https://ultimatecourses.com/courses/rxjs](https://ultimatecourses.com/courses/rxjs) [Rxjs ultimate](https://legacy.gitbook.com/book/chrisnoring/rxjs-5-ultimate/details) https://www.jianshu.com/p/1a90e39ec658 https://www.learnrxjs.io/ https://legacy.gitbook.com/book/gianttoast/rxjs-observables/details [将RxJS融入React项目](https://segmentfault.com/a/1190000013141856) [30 天精通 RxJS](https://ithelp.ithome.com.tw/articles/10186103) [[译] RxJS: 6个你必须知道的操作符](https://zhuanlan.zhihu.com/p/27997606)