[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 ...
随机推荐
- c++ 连接两个字符串实现代码 实现类似strcat功能(转)
想实现strcat功能,直接网上找一个. 第一种: #include "stdafx.h" #include<iostream> using namespace std ...
- Java基础知识强化52:经典排序之冒泡排序(BubbleSort)
1. 冒泡排序的原理图: 2. 冒泡排序代码实现: package cn.itcast_01; /* * 数组排序之冒泡排序: * 相邻元素两两比较,大的往后放,第一次完毕,最大值出现在了最大索引处 ...
- Linux系统调用system_call
2016-03-25 张超的<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 我的虚拟环境和代码在http ...
- 你的sscanf用对了吗
用sscanf解析输入字符串 我们平常编写的很多应用程序都会处理各种各样的输入,这些输入或来自本地文件,或来自网络,或来自用户的输入.今天,让我们来看看sscanf这个和字符串相关的函数可能给你带来的 ...
- ComboBox( 下拉列表框)
一. 加载方式//class 加载方式<select id="box" class="easyui-combobox" name="box&qu ...
- GridView控件的光棒效应
// 光棒效应 protected void gvBookInfos_RowDataBound(object sender, GridViewRowEventArgs e) { if(e.Row.Ro ...
- Linux 数据 CD 刻录
http://www.cyberciti.biz/tips/linux-burning-multi-session-cds-on-linux.html #mkisofs -dvd-video -inp ...
- Arcgis Server ecp(许可)
Arcgis Server 10 许可(新建.txt文件,然后拷贝好以下内容,然后修改为 .ecp文件即可): 3dengine,100,ecp.arcgis.server,none,KGE784S1 ...
- 初学Java ssh之Spring 第二篇
上一篇我们成功搭建好了spring开发的环境,接下来一起看看spring有什么神奇的地方吧(本人也是新手,有不太对的地方希望大神给指出便于修改呢,谢谢大家). 之前听说spring是在对xml文件的应 ...
- 转载:mysql-Auto_increment值修改
转载网址:http://libo93122.blog.163.com/blog/static/1221893820125282158745/ | 2012-03-13 11:19:10 | 2012- ...