Skip to content

Instantly share code, notes, and snippets.

@odoe

odoe/LocatorView.js

Last active Aug 29, 2015
Embed
What would you like to do?
// original AMD syntax
define([
'dojo/_base/declare',
'dijit/_WidgetBase',
'dijit/_TemplatedMixin',
'dbind/bind',
'stores/LocatorStore',
'helpers/NumFormatter',
'dojo/text!./templates/LocatorView.html'
], function(
declare,
_WidgetBase, _TemplatedMixin,
bind, store, format,
template
) {
var fixed = format(3);
return declare([_WidgetBase, _TemplatedMixin], {
templateString: template,
postCreate: function() {
var xStore = bind(fixed).to(store, 'x');
var yStore = bind(fixed).to(store, 'y');
bind(this.yNode).to(yStore);
bind(this.xNode).to(xStore);
}
});
});
// ES6 syntax
import declare from 'dojo/_base/declare';
import _WidgetBase from 'dijit/_WidgetBase';
import _TemplatedMixin from 'dijit/_TemplatedMixin';
import bind from 'dbind/bind';
import store from 'stores/LocatorStore';
import format from 'helpers/NumFormatter';
import template from 'dojo/text!./templates/LocatorView.html';
var fixed = format(3);
// export the module, not return it
export default declare([_WidgetBase, _TemplatedMixin], {
templateString: template,
postCreate() { // notice no function keyword
var xStore = bind(fixed).to(store, 'x');
var yStore = bind(fixed).to(store, 'y');
bind(this.yNode).to(yStore);
bind(this.xNode).to(xStore);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment