ElixirScript.Lib.JS

Summary

Imports a JavaScript module

Creates new JavaScript objects

Updates an existing JavaScript object

Macros

import(module, from)

Imports a JavaScript module.

Elixir modules can use the normal import, alias and require, but JavaScript modules work differently and have to be imported using this.

If module is not a list, then it is treated as a default import, otherwise it is not.

ex: JS.import A, “a” #translates to “import {default as A} from ‘a’”

JS.import [A, B, C], “a” #translates to “import {A, B, C} from ‘a’”

new(module, params)

Creates new JavaScript objects.

ex: JS.new User, ["first_name", "last_name"]

update(object, property, value)

Updates an existing JavaScript object.

ex: JS.update elem, “width”, 100