-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNgReduxComponent.js
31 lines (31 loc) · 1.2 KB
/
NgReduxComponent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var NgReduxComponent = /** @class */ (function () {
function NgReduxComponent(inputMapper, changeDetectorRef) {
this.inputMapper = inputMapper;
this.changeDetectorRef = changeDetectorRef;
this.props = {};
this.init();
}
NgReduxComponent.prototype.init = function () {
var _this = this;
this.unsubscribeStore = NgReduxComponent.store.subscribe(function () {
_this.onStoreChange(NgReduxComponent.store);
if (_this.changeDetectorRef) {
_this.changeDetectorRef.markForCheck();
}
});
this.onStoreChange(NgReduxComponent.store);
};
NgReduxComponent.prototype.ngOnInit = function () {
// noop, this ensures angular calls any overrides further down the ctor chain
};
NgReduxComponent.prototype.ngOnDestroy = function () {
this.unsubscribeStore();
};
NgReduxComponent.prototype.onStoreChange = function (store) {
this.props = Object.assign({}, new this.inputMapper(store.getState()), { state: null });
};
return NgReduxComponent;
}());
exports.NgReduxComponent = NgReduxComponent;