UNPKG

1.13 kBJavaScriptView Raw
1"use strict";
2var hmr_store_1 = require('./hmr-store');
3function HmrState(namespaceOrConfig, config) {
4 function decoratorFactory(target, decoratedPropertyName, descriptor) {
5 var key = namespaceOrConfig || target.constructor.name + '#' + decoratedPropertyName;
6 hmr_store_1.HmrStore.select(key, function () { return hmr_store_1.HmrStore.get(key); });
7 Object.defineProperty(target, decoratedPropertyName, {
8 get: function () { return hmr_store_1.HmrStore.get(key); },
9 set: function (newValue) {
10 var currentValue = hmr_store_1.HmrStore.get(key);
11 if (!currentValue) {
12 hmr_store_1.HmrStore._initialValues[key] = newValue;
13 }
14 else {
15 newValue = Object.assign(newValue, currentValue);
16 }
17 return hmr_store_1.HmrStore.set(key, newValue);
18 },
19 enumerable: true,
20 configurable: true
21 });
22 return descriptor;
23 }
24 return decoratorFactory;
25}
26exports.HmrState = HmrState;
27//# sourceMappingURL=hmr-decorator.js.map
\No newline at end of file