自己感觉学习reactiveX rxjs 的operator,最好的方法不是

读文档https://rxjs.dev/guide/overview

读书https://book.douban.com/subject/30217949/

甚至不是示例代码:

 

而是看图

https://rxmarbles.com/

plot marble diagram as svg

选择一个operator, 然后看图,然后拖拽每个珠子(emitted item)的位置,看结果,是最容易理解的。不用特意记,用到那个查哪个

 

但是,这是在线版的,如果要离线作图。或者抛开rx的算符,做任意的弹珠图,比如还不知道pipe设计成啥样,但是想把期望时序处理输入输出的marble画出来。

这时候需要这个https://bitbucket.org/achary/rx-marbles

py库,简单的DSL描述任意的marble,用txt格式保存,然后输出为svg。

直接pip安装

pip install rxmarbles
注意win下要确认一下安装位置加入到了PATH:
C:\Users\XXX\AppData\Roaming\Python\Python38\Scripts

我在github上把DSL摘要和它的syntax.md里的实例都搞出来了

https://github.com/xuqinghan/learn-rxmarbles

比如

txt文件:

marble grouped
{
    source foo:     +-{1,2}-{3,4,5}-{6,7}-|
}

执行

marblesgen grouped.txt

svg:

plot marble diagram as svg

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2021-04-25
  • 2021-06-26
  • 2021-12-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-02
  • 2022-01-11
  • 2021-09-18
  • 2021-06-14
  • 2021-07-29
相关资源
相似解决方案