10 Kiffs.

Stimulus: a javascript framework for people who love html

Stimulus: a javascript framework for people who love html
Vishal Vishal 22 February, 2018

Stimulus is a “modest JavaScript framework”, built by the folks at Basecamp who brought you Rails.

It is, in many ways, the opposite of other modern frameworks available today. While you might see some similar concepts and naming, Stimulus is very different in some fundamental ways. We’ll discuss those differences briefly, and then build our first application with Stimulus.

The DOM: A Place for State?

The core concepts of many modern frameworks lie in separating “state” from the “DOM”. In this way, the DOM acts only as a client to the data it is representing.

Stimulus flips this concept on its head, and instead relies on the DOM to hold state.

What this ultimately means is that Stimulus is best suited for applications that serve HTML (rather than, for example, integrating with a JSON API).

With Stimulus, you won’t see HTML templates. Instead, you will see data-* attributes that connect the HTML to the JavaScript application.

This also means you won’t see things like each or map loops like you might see in Handlebars or React.

Stimulus doesn’t hold the job of rendering HTML unless you explicitly create that functionality.

So Stimulus doesn’t render templates. Rather it is built to connect actions and events you take on the front end of an application to controllers on the back end.

Stimulus uses three concepts to accomplish this: targets, controllers, and actions.

But before we get too far in, let’s go ahead and get Stimulus up and running on your computer!

This setu...
Read on webdesign.tutsplus.com

Flag |
Category: Dev & Design
Tags: Dev, tutsplus

No comments yet, be the first one to post comment.

To post your comment please Login or Join