Binding to Existing Functions

There’s a more satisfying way to use the functions in the JavaScript Date object: write a binding that tells ReasonML how it should communicate with them. Before writing your own bindings, you may want to visit the Reason Package index at https://redex.github.io to see if the needed bindings already exist. You can also try doing an npm search for bs- as a prefix to the package name whose bindings you want.

Although there’s already a set of bindings for Date,[32] it’s good for us to derive some of them ourselves so we’re ready when we come across a library that doesn’t have bindings. Among the things we’ll do from ReasonML:

  • Create a new Date object.

  • Call class-level methods such as now, which returns the number ...

Get Web Development with ReasonML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.