CommonJS and ender-inspired require/provide with events
$ npm install cmon
cmon(id)
- delegates tocmon.require(id)
cmon(id, value)
- delegates tocmon.provide(id, value)
cmon(id, value, guard)
- delegates tocmon.require(id)
cmon(callback)
- runs in the root scope and receives(cmon)
At runtime in a browser cmon
claims the global require
/provide
if unclaimed. Otherwise access them as methods:
cmon.require(id)
- get a module that was provided viacmon.provide
cmon.provide(id, value)
- provide a modulecmon.provide.on(id, handler)
- attach a handler to run anytimeid
is providedcmon.provide.one(id, handler)
- attach a 1-time handler to run the next timeid
is providedcmon.provide.able(id, handler)
- attach a 1-time handler to run whenid
is available—now or later.cmon.provide.off(id, handler)
- remove a handlercmon.provide.off(id)
- remove allid
handlerscmon.provide.trigger(id)
- manually trigger activeid
handlers
cmon.claim(id, value, opt_scope)
- expose a module to the root oropt_scope
cmon.unclaim(id, value, opt_scope)
- safely unexpose a module that was exposed via claim
cmon.noConflict()
- unclaimrequire
/provide
cmon.noConflict(true)
- unclaimrequire
/provide
/cmon
cmon.noConflict(callback)
- unclaimrequire
/provide
/cmon
cmon is available under the MIT license
Copyright (C) 2013 by Ryan Van Etten