Overview - OwlTechnology/ComfyJs GitHub Wiki

This is an overview of ComfyJS, a lightweight Javascript framework that handles common tasks required by all webapps quickly, performantly, and with little overhead.

Module System

In addition to the baseline API that this plugin provides, it also provides an elegant, simple way of importing self-contained HTML/JS modules. This system is flexible enough to support whatever framework you are using, backend or frontend.

$require(modulePath: url<string>, name: string)

Imports the module specified by the URL. The module will be loaded dynamically, and an event will be fired when the module is ready to be used, called "modules.loaded.[name]", where name is the module name specified in the $require(...).

$requireHTML(modulePath: url<string>, jsPath: url<string>, name: string)

Imports the HTML module and it's Javascript controller to be used in the paged. The module will be loaded dynamically, and an event will be fired when the module is ready to be used, called "modules.loaded.[name]", where name is the module name specified in the $requreHTML(...).

Example Usage:

$reqireHTML('/modules/MyModule.html', '/modules/js/MyModule.js', 'MyModule');

$on('modules.loaded.MyModule', function(factory){
    // gets an instance of the Javascript controller module that includes
    // a new block of DOM based on the module HTML
    var instance = factory.instance();

    instance.addToDOM(parentElement);
});
⚠️ **GitHub.com Fallback** ⚠️