Hello there,
I am looking for an example of creating an object in ReasonML/Bucklescript. I have been hitting my head trying to create an instance of the class that is defined in the documentation on the Bucklescript site, but I’m not making any progress. I am going to skip ahead in “Real World OCaml” tonight and see if I can make any sense of the chapter on objects.
Other questions I have are:
- Do I have to define methods inline?
- Do classes get compiled into JS objects or ES6 classes?
- Does the Bucklescript compiler fully support the object-oriented features of OCaml?
I’ll post the example code here as well:
class type _rect =
[@bs]
{
[@bs.set] pub height: int;
[@bs.set] pub width: int;
pub draw: unit => unit
};
type rect = Js.t(_rect);