Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rxjs fun code #152

Open
zzz6519003 opened this issue May 4, 2022 · 1 comment
Open

rxjs fun code #152

zzz6519003 opened this issue May 4, 2022 · 1 comment
Labels

Comments

@zzz6519003
Copy link
Owner

郭靖和黄蓉一起背书,黄蓉记忆力很好,看了什么,就全部记得;而郭靖属鱼的,记忆只有七秒,始终只记得背诵的最后三个字,两人一起背诵《九阴真经》。

代码实现如下:

const 九阴真经 = '天之道,损有余而补不足'

const 黄蓉$ = new ReplaySubject(Number.MAX_VALUE)
const 郭靖$ = new ReplaySubject(3)

const 读书$ = Observable.from(九阴真经.split(''))

读书$.subscribe(黄蓉$)
读书$.subscribe(郭靖$)

执行之后,我们就可以看到,黄蓉背出了所有字,郭靖只记得“补不足”三个字。

@zzz6519003
Copy link
Owner Author

@zzz6519003 zzz6519003 changed the title rxjs rxjs fun code May 4, 2022
@zzz6519003 zzz6519003 added the fun label May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant