[Cycle.js] Hello World in Cycle.js

Source: Internet
Author: User

Now you should has a good idea what cycle.run does, and what's the DOM Driver is. In this lesson, we'll not build a toy version of Cycle.js anymore. Instead, we'll learn how to use cycle.js to solve problems. We'll start by making a simple Hello world application.

const {label, input, HR, H1, div, makedomdriver} =Cycledom;functionMain (sources) {//Read from driver, select '. Field ' class bind with input event.Const inputevent$ = sources. Domm.select ('. field '). Events (' input '); //Each input event would map to it ' s value  //Because At first there are no input, so we mock one by using Startwith (')Const name$ = inputevent$.map (ev = ev.target.value). Startwith ("); return {    //Each name event would output the CycledomDomm:name$.map (name = {      returnDiv ([Label (' Name: '), input ('. Field ', {type: ' text '}), HR (), H1 (' Hello ${name} ')]})}; Const drivers={domm:makedomdriver (' #app ')}cycle.run (main, drivers);

[Cycle.js] Hello World in Cycle.js

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.