The guiding principle in Cycle.js is we want to separate logic from effects. This first part here was logical, and this second part here was effects. Effects are everything that change the external world somehow, the real world such as the DOM is connected to the browser, which is the connected to the user, so when we do something like set the text content, we are changing the screen that will shown to the user. So things like console.log and HTTP network requests, all of these things are effects, and these things live in subscribes.

Logic on the other hand, this is not changing the external world anyhow, it's just an event stream of numbers every second, and we're mapping that event stream to another event stream with strings. This part here is functional, it's all about mapping some primitives to others, and this side is imperatives. Our guiding principle for Cycle.js is we want to push subscribes as far away as we can from our app.

So this part of subscribe we want this to live in the framework, and this part is the only thing that the developer will write as the app. That is the guiding principle to separate logic from effects.

console.clear();
// Logic
Rx.Observable.timer(0,1000)
.map( i => `Second elapsed ${i}`) // Effect
.subscribe( text => console.log(text))

最新文章

  1. Bzoj3894 文理分科
  2. web----test-----selenium
  3. 2015年辽宁省赛Interesting Tree
  4. Linux文件系统(inode、block……)
  5. [转]玩转Google开源C++单元测试框架Google Test系列
  6. 实现系统函数time,获取当前时间与UTC的间隔
  7. vijosP1006 晴天小猪历险记之Hill
  8. Log4Net配置注意点
  9. Win7+CentOS双系统(一)
  10. Hive语法
  11. linux 保存git的账号密码
  12. xirr函数
  13. springcloud feign传输List的坑
  14. 修改maven的默认jdk版本
  15. day29akka
  16. 20145225唐振远《网络对抗》Exp4 恶意代码分析
  17. BZOJ1135:[POI2009]Lyz(线段树,Hall定理)
  18. Post Lamps CodeForces - 990E(暴力出奇迹?)
  19. MapReduce: number of mappers/reducers
  20. solr查询优化(实践了一下效果比较明显)

热门文章

  1. Ubuntu 14.04 下手动安装Firefox的Flash插件
  2. 浅谈Java内存及GC
  3. chmod
  4. (转)JQuery处理json与ajax返回JSON实例
  5. MongoVUE查询备忘
  6. java对像序列化
  7. PHP的curl常用的5种写法
  8. PS 色彩的色相谱
  9. C 语言简历一个文件夹 并自己输入字符 来取文件夹名字
  10. EAT/IAT Hook