emit dom controllers
npm install @emit-js/emit @emit-js/controller
const emit = require("@emit-js/emit")()
require("@emit-js/controller")(emit)
First create your controller composer:
module.exports = function(emit) {
emit.controller("myController", myController)
}
async function myController() {
// control stuff
}
Then use it:
require("./myController")(emit)
emit.myController()
Commonly we append the controller name to the prop
array and pass the concatenated props to sub-events.
Passing those props down produces descriptive element ids and logs that describe the call stack.
Luckily, the controller
composer injects the controller name into the prop
array automatically, eliminating the controller name append step.
ℹ️ Prop injection is the only thing the controller composer does at this point in time.
Library | Description | URL |
---|---|---|
el | DOM elements | https://github.com/emit-js/el#readme |
render | Server side render | https://github.com/emit-js/render#readme |
view | DOM views | https://github.com/emit-js/view#readme |