Summing Up
You now know how to use bs-webapi to interact with a web page by getting an element by its id attribute, attaching an event listener to a button, retrieving a form value, and setting an element’s text. You’ve seen how we can use Belt.Option.map and Belt.Option.flatMap to handle invalid data in a type-safe way without null or undefined issues.
bs-webapi is fairly low-level—if you use it a great deal, you’ll find yourself writing utility functions to handle common situations. Eventually, you may want to create a full-blown single-page application. ReasonML is very tightly integrated with React (https://reactjs.org/), as you’ll see in Chapter 9, Making Applications with Reason/React.
Before we get there, though, we have to finish ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access