Skip to content

Instantly share code, notes, and snippets.

@kristoferjoseph
Last active December 20, 2015 10:09
Show Gist options
  • Save kristoferjoseph/6113736 to your computer and use it in GitHub Desktop.
Save kristoferjoseph/6113736 to your computer and use it in GitHub Desktop.
Example of a Require.js Common.js style module that expose an API to the application. Similar to how Reflow does it.
define(function (require, exports, module) {
'use strict';
//Requires
var EventMap = require('modules/utils/eventmap'),
FontModel = require('modules/fonts/models/fontmodel'),
FontView = require('modules/fonts/views/fontview'),
fontModel = new FontModel(),
fontView;
//Initialization
var viewInitializedHandler = function viewInitializedHandler() {
//View
fontView = new FontView({
model: fontModel
});
};
//Guts
var save = function () {
return fontModel.save();
};
var load = function (data) {
fontModel.load(data);
};
//App Events
EventMap.subscribe("App:initialized", viewInitializedHandler);
//API
exports.save = save;
exports.load = load;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment