Skip to content

Instantly share code, notes, and snippets.

@andersevenrud
Last active August 29, 2015 14:25
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 andersevenrud/c2e84548a3c0af8c7150 to your computer and use it in GitHub Desktop.
Save andersevenrud/c2e84548a3c0af8c7150 to your computer and use it in GitHub Desktop.
OSjs Module Example
//
// Example: src/javascript/helpers/my-module.js
// Add to: `src/conf/200-compile.json`
// Then run: `grunt dist-dev-index` to add to dist-dev build
// Or: `grunt core` to add to dist build
//
(function(Utils, VFS, API) {
/////////////////////////////////////////////////////////////////////////////
// MODULE API
/////////////////////////////////////////////////////////////////////////////
// Just a basic pattern to keep methods
var MyModule = {
someMethod: function() {
}
};
/////////////////////////////////////////////////////////////////////////////
// EXPORTS
/////////////////////////////////////////////////////////////////////////////
// Available namespaces: API, VFS, Utils, Helpers, Core
// Helpers is what I call the generic libraries... because they "help you"
OSjs.Helpers.MyModule = MyModule;
})(OSjs.Utils, OSjs.VFS, OSjs.API);
//
// Then somewhere in your application code
// Just an example
//
MyApplication.prototype.something = function() {
OSjs.Helpers.MyModule.someMethod();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment