Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canonic-epicure/384166 to your computer and use it in GitHub Desktop.
Save canonic-epicure/384166 to your computer and use it in GitHub Desktop.
// ================================================
// Using CommonJS modules in Joose - with dependencies
Module('Graphic.Circle', {
require : [ './some/commonjs/module1.js', './some/commonjs/module2.js' ],
use : {
'Some.Joose.Role' : 0.01,
'Some.Another.Class' : 0.02
},
body : function (module) {
// this == Graphic.Circle
// module == Graphic.Circle
// will be already loaded
var someFunc = require('./some/commonjs/module1.js').someFunc
Class('.Graphic.Circle', {
does : Some.Joose.Role,
has : {
radius : {
is : 'rw',
init : '123'
}
},
methods : {
draw : function () {
someFunc1("using imported function")
}
}
})
}})
var circle = new Graphic.Circle()
circle.draw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment