Modules - Client
Client modules are independent closures, that can include CommonJS. They are automatically collected, browserified, joined together, and minified by the bundler.
All "magic" is in require directive. There are several types of
requireable files:
- "vendor" libraries - embedded with global path (or shortname). Should be announced in bundler config. Used for global libraries, like "lodash".
- "local" libraries - works as in node.js, embedded once per package.
Also there are some extra stuff available within Nodeca's client modules over CommonJS specification:
- module.apiPath - contains API path of the module. (e.g.
forum.section) - N - local reference to N object.
- t - local wrapper over
N.runtime.tallows to use translation paths relative to the module's API path.
Wire listeners
There are some common events, that can be emitted from any modules:
- navigate.to - go to another page
- __navigate.exit:
- fired, prior to leave page with certain api path. Useful for resourses cleanup. - navigate.exit - the same as above, but global (fired every time we leave any page). Can be used to control global page objects
- navigate.done:
- fired page with certain api path, after data loaded and rendering compleete. Useful to init internal structures, that depends on DOM and another scripts. Can be used instead of $(function(){...}), but for one page - navigate.done - the same as above, but global (fired every time for all pages). Can be used instead of $(function(){...})
- notify - show popup message in top right corner