Last active
December 20, 2015 10:09
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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