bs-atom
Complete Atom API bindings for BuckleScript (as for 1.40.1
)
All pull request are welcome
Installation
npm install --save bs-atom
Then add bs-atom
to bs-dependencies
in your bsconfig.json
:
... "bs-dependencies": "bs-atom"
Usage
For managers like ViewRegistry
or Config
that are instantiated by Atom under the atom
global.
Access them from the Atom
module:
Atom.Config.set("core.themes", [|"atom-light-ui", "atom-light-syntax"|]);
Instances of class like TextEditor
would have type Atom.TextEditor.t
.
Methods are invoked in the pipe last fashion:
textEditor |> Atom.TextEditor.getTextInBufferRange(range);
Use make
to construct instances of classes like Point
s or Range
s:
let p = Atom.Point.make(0, 3);
also, they come with getters:
let row = p.row;
Uncharted modules
How to deal with optional arguments
Some functions may have options. Take Atom.TextEditor.setText
for example:
setText: (string, t) => unit
setText
may take an an extra JS object as the second argument. We suffix these "opinionated" functions with _
.
setText_: (string, {. "bypassReadOnly": bool}, t) => unit
Options with optional fields
atom.config.set
may take an extra argument:
atomconfig
Both scopeSelector
and scope
in the object may be omitted.
Instead of having 4 variants of setText_
, we simply type those optional fields as option(...)
.
set_: (string, value, { . "scopeSelector": option(string), "source": option(string),}) => bool
Atom.config.set_("core.themes", [|"atom-light-ui"|], { . "scopeSelector": Some([|"source.js"|]), "source": None});
Note: not all optional fields of options are typed this way