February 2019
Beginner to intermediate
180 pages
4h 4m
English
When binding to existing JavaScript APIs, think about how you'd like to use the API in Reason. Even existing JavaScript APIs that rely heavily on JavaScript's dynamic typing can be used in Reason. BuckleScript leverages advanced type system techniques that let us take advantage of Reason's type system with such APIs.
From the BuckleScript documentation, take a look at the following JavaScript function:
function padLeft(value, padding) { if (typeof padding === "number") { return Array(padding + 1).join(" ") + value; } if (typeof padding === "string") { return padding + value; } throw new Error(`Expected string or number, got '${padding}'.`);}
If we were to bind to this function in Reason, it would be nice to use padding as ...
Read now
Unlock full access