The 'h' Function of Virtual Hyperscript

Learn about the drivers of Cycle.js and the functions used in the user interface.

We'll cover the following

Cycle.js drivers

Cycle.js drivers are functions that we use to cause side effects. Nowhere else in our programs should we modify the state in any way. Drivers take an Observable that emits data from our application and return another Observable that causes the side effects.

We won’t need to create drivers very often—only when we need side effects like modifying the DOM, reading and writing from other interfaces (for example, Local Storage), or making requests. In most applications, we’ll need only the DOM driver and the HTTP driver which renders webpages and that which we use to make HTTP requests, respectively. In this example, we’ll use yet another DOM driver known as the JSONP driver.

The user interface

We need actual content for our page, not just a span. Let’s make a function that creates the virtual tree that represents our page:

Get hands-on with 1400+ tech skills courses.