/** * A centralized module for handling the assigning and loading of formatter * implementations. */ define([ 'dojo/_base/declare', "dojo/Deferred" ], function(declare, Deferred) { var Formatter = declare(null, { constructor : function() { for (var i in formatInfo) { Formatter.prototype[i] = { info : formatInfo[i], formatterImpl : null, load : function(module, deferred) { require([ module ], function(FormatterImpl) { deferred.resolve(FormatterImpl); }); }, init : function(callback) { var me = this; if (!me.formatterImpl) { var f = new Deferred(); f.then(function(FormatterImpl) { me.formatterImpl = new FormatterImpl( me.info); if (callback) { callback(); } }); var formatterModule = this.info.path .indexOf("/") > 0 ? this.info.path : "siemens/formatting/" + this.info.path; this.load(formatterModule, f); } if (callback) { callback(); } }, format : function(value, callback) { return this.formatterImpl.format(value) }, unformat : function(value, callback) { return this.formatterImpl.unformat(value) } }; this[i].init(); } } }); return new Formatter(); });