Light talk about the upcoming features of Stimulus.js.
Stimulus 2.0-alphaWhat’s new?
View Slide
TLDRTwo new APIs with a nice surprise
Data Map API
Data Map API● A way to pass data to a controller.● Use cases:○ Storing small strings, such as URLs, dates, orcolor values;○ Bootstrapping a controller with a JSON objector array.
HTML Controller
However, the Data Map API only workswith string values. That means we mustmanually convert to and from othertypes as needed
Values API
Values API● Makes possible to define values (datamaps) in the controller itself;● Create properties to accessing them.
UsageThe Value object keysare Data Map keys,and the values declaretheir data types
ValuePropertiesThey work just as theTarget API works
A nice surprise:Value Changed Callback
UsageNow it’s easier tomake your good oldHTML template lookmodern
How many times haveyou seen the followingpattern?
We’re coupling thecontroller to the classname
Maybe using the DataMap API?
Classes API
All that with a verysmall cost
Unifying targetattributesBoth syntaxes will besupported, but usingthe original syntax willdisplay a deprecationmessage in thedeveloper console
Excited? Startusing it now!Just add it to yourpackage.json
More info athttps://github.com/stimulusjs/stimulus/pull/202
That’s itFeel free to ask any question