[Cycle.js] Main function and effects functions
We need to give structure to our application with logic and effects. This lessons shows how we can organize our code into two parts: main() function for logic, and effects functions for effects.
// Logic (functional)
function main() {
return Rx.Observable.timer(0, 1000)
.map(i => `Seconds elapsed ${i}`);
} // Effects (imperative)
function DOMEffect(text$) {
text$.subscribe(text => {
const container = document.querySelector('#app');
container.textContent = text;
});
} function consoleLogEffect(msg$) {
msg$.subscribe(msg => console.log(msg));
} const sink = main();
DOMEffect(sink);
consoleLogEffect(sink);
[Cycle.js] Main function and effects functions的更多相关文章
- [Cycle.js] Introducing run() and driver functions
Currently the code looks like : // Logic (functional) function main() { return { DOM: Rx.Observable. ...
- The App Life Cycle & The Main Function
The App Life Cycle Apps are a sophisticated interplay between your custom code and the system framew ...
- [Cycle.js] Customizing effects from the main function
How can we show one string on the DOM, and a completely different string on Console log? This lesson ...
- [Cycle.js] Read effects from the DOM: click events
So far we only had effects that write something to the external world, we are not yet reading anythi ...
- [Cycle.js] The Cycle.js principle: separating logic from effects
The guiding principle in Cycle.js is we want to separate logic from effects. This first part here wa ...
- [Cycle.js] Generalizing run() function for more types of sources
Our application was able to produce write effects, through sinks, and was able to receive read effec ...
- [Cycle.js] From toy DOM Driver to real DOM Driver
This lessons shows how we are able to easily swap our toy DOM Driver with the actual Cycle.js DOM Dr ...
- 学习RxJS:Cycle.js
原文地址:http://www.moye.me/2016/06/16/learning_rxjs_part_two_cycle-js/ 是什么 Cycle.js 是一个极简的JavaScript框架( ...
- [Cycle.js] Fine-grained control over the DOM Source
Currently in our main() function, we get click$ event. function main(sources) { const click$ = sour ...
随机推荐
- linux 远程自动登录脚本 (注test.exp)
#! /usr/bin/expect set timeout 30spawn ssh -l root 192.168.239.148 expect "password:"send ...
- android常用软件下载资源链接
最新内容请看:http://www.androiddevtools.cn/ https://github.com/inferjay/AndroidDevTools 官方adt下载地址:http://d ...
- passwd-shadow文件
[root@rusky /]# vi /etc/passwd root:x:::Redhat5:/root:/bin/bash rusky:x::::/home/rusky:/bin/bash 1.r ...
- CSS Hack是什么意思
CSS hack由于不同的浏览器,比如Internet Explorer 6,Internet Explorer 7,Mozilla Firefox等,对CSS的解析认识不一样,因此会导致生成的页面效 ...
- JavaScript: Class.method vs Class.prototype.method
在stack overflow中看到一个人回答,如下 // constructor function function MyClass () { var privateVariable; // p ...
- Beacon浅析
作者:hongbosun 一.Beacon简介 Beacon是基于BLE技术实现的物理设备.BLE(全称Bluetooth Low Energy)是蓝牙4.0技术规范的一部分.它起源于Nokia的Wi ...
- C3P0连接池配置方式
c3p0的配置方式分为三种,分别是 1.setters一个个地设置各个配置项 2.类路径下提供一个c3p0.properties文件 3.类路径下提供一个c3p0-config.xml文件 1.set ...
- Canvas--2
Canvas2(关键词:setLineDash .rect .strokeRect .clearRect .arc.sin .strokeText ) 绘制其他样式: lineCap 结束端点的设 ...
- Linux 软链接和硬链接的理解与学习
理解前提: 首先要知道 Linux任意一个文件包含2个信息:第一个信息就是文件本身存的内容,第二个信息是文件的控制信息(读写,路径,大小等等),这2个信息是分开存储的,明白这点非常重要 理解总结: L ...
- 自己写的简单的jQuery分页控件
因为是内部项目,需要分页控件,网上找了一大堆,给领导一看,都说不行,原因很简单,太复杂,领导就想要个简单点的,类似百度的分页,可是自己也没写过Jquery控件,硬着头皮找了些资料,写了这个分页控件,目 ...