Skip to content

Instantly share code, notes, and snippets.

@xjamundx
Last active December 18, 2015 02:19
Show Gist options
  • Save xjamundx/5710275 to your computer and use it in GitHub Desktop.
Save xjamundx/5710275 to your computer and use it in GitHub Desktop.
oj3.service.js
// oj3 implementation
angular.module('odesk').factory('oj3', function() {
return {
widgets: odesk.mediator.widgets,
trigger: function($scope, event, data) {
// i don't know, we aren't an instance
},
registerWidget: function(name, $scope) {
// this won't quite work, because $scope doesn't talk OJ3 events
oj3.registerWidget(name, $scope);
},
subscribe: function(widget, event, cb) {
// something like this might actually work
oj3.widgets[widget][event].subscribe(cb);
}
}
});
angular.module('MCCtrl').controller(function($scope, oj3) {
oj3.registerWidget('MCCtrl', $scope);
oj3.trigger("update", "We are great");
oj3.subscribe("AutoCompleter", "update" function() {
alert('auto-completer updated!');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment