Skip to content

Commit

Permalink
Add decorator interceptor 🎭
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliy-bobrov committed May 18, 2017
1 parent 9866ce6 commit 3ec8fc7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.5
### Bug Fixes:
- Fixed **decorator**: Add decorator invoke.

## 0.9.4
### Bug Fixes:
- Fixed **filter**: Add filter invoke.
Expand Down
24 changes: 13 additions & 11 deletions lib/angular-hot-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ var HotAngular = function(settings) {
this.configCache = {};
this.constantCache = {};
this.controllerCache = {};
this.decoratorCache = {};
this.factoryCache = {};
this.filterCache = {};
this.serviceCache = {};
this.valueCache = {};
this.templateCache = {};
this.filterCache = {};

this.name;
this.bootstrapElement;
Expand Down Expand Up @@ -74,19 +75,20 @@ var HotAngular = function(settings) {
};

// Angular functions to replace
HotAngular.prototype.run = require('./interceptors/run');
HotAngular.prototype.value = require('./interceptors/value');
HotAngular.prototype.module = require('./interceptors/module');
HotAngular.prototype.config = require('./interceptors/config');
HotAngular.prototype.filter = require('./interceptors/filter');
HotAngular.prototype.factory = require('./interceptors/factory');
HotAngular.prototype.service = require('./interceptors/service');
HotAngular.prototype.constant = require('./interceptors/constant');
HotAngular.prototype.provider = require('./interceptors/provider');
HotAngular.prototype.animation = require('./interceptors/animation');
HotAngular.prototype.directive = require('./interceptors/directive');
HotAngular.prototype.component = require('./interceptors/component');
HotAngular.prototype.config = require('./interceptors/config');
HotAngular.prototype.constant = require('./interceptors/constant');
HotAngular.prototype.controller = require('./interceptors/controller');
HotAngular.prototype.decorator = require('./interceptors/decorator');
HotAngular.prototype.directive = require('./interceptors/directive');
HotAngular.prototype.factory = require('./interceptors/factory');
HotAngular.prototype.filter = require('./interceptors/filter');
HotAngular.prototype.module = require('./interceptors/module');
HotAngular.prototype.provider = require('./interceptors/provider');
HotAngular.prototype.run = require('./interceptors/run');
HotAngular.prototype.service = require('./interceptors/service');
HotAngular.prototype.value = require('./interceptors/value');

HotAngular.prototype.reloadState = function() {
var elm = this.bootstrapElement;
Expand Down
22 changes: 22 additions & 0 deletions lib/interceptors/decorator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = function(name, decoratorFunction) {
var exists = this.MODULE_CACHE[name];
this.decoratorCache[name] = decoratorFunction;

this.logger(`DECORATOR "${name}":
${decoratorFunction}`, 'info');

if (exists) {
this.decoratorInject = decoratorFunction;

this.bootstrapElement.injector().invoke([name, function(decorator) {
decorator = this.decoratorInject;
}], this);

this.reloadState();
} else {
this.MODULE_CACHE[name] = true;
this.ANGULAR_MODULE.decorator(name, this.decoratorCache[name]);
}

return this;
};

0 comments on commit 3ec8fc7

Please sign in to comment.