@angular-redux/store
Advanced tools
Comparing version 6.5.0-alpha.8 to 6.5.0-alpha.9
@@ -7,2 +7,2 @@ /** | ||
*/ | ||
export declare const dispatch: () => (target: Object, key: PropertyKey, descriptor?: PropertyDescriptor | undefined) => any; | ||
export declare function dispatch(): PropertyDecorator; |
@@ -11,29 +11,32 @@ "use strict"; | ||
*/ | ||
exports.dispatch = function () { return function (target, key, descriptor) { | ||
var originalMethod; | ||
var wrapped = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
function dispatch() { | ||
return function decorate(target, key, descriptor) { | ||
var originalMethod; | ||
var wrapped = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var result = originalMethod.apply(this, args); | ||
var store = helpers_1.getBaseStore(this) || ng_redux_1.NgRedux.instance; | ||
store.dispatch(result); | ||
return result; | ||
}; | ||
descriptor = descriptor || Object.getOwnPropertyDescriptor(target, key); | ||
if (descriptor === undefined) { | ||
var dispatchDescriptor = { | ||
get: function () { return wrapped; }, | ||
set: function (setMethod) { return originalMethod = setMethod; }, | ||
}; | ||
Object.defineProperty(target, key, dispatchDescriptor); | ||
return dispatchDescriptor; | ||
} | ||
var result = originalMethod.apply(this, args); | ||
var store = helpers_1.getBaseStore(this) || ng_redux_1.NgRedux.instance; | ||
store.dispatch(result); | ||
return result; | ||
else { | ||
originalMethod = descriptor.value; | ||
descriptor.value = wrapped; | ||
return descriptor; | ||
} | ||
}; | ||
descriptor = descriptor || Object.getOwnPropertyDescriptor(target, key); | ||
if (descriptor === undefined) { | ||
var dispatchDescriptor = { | ||
get: function () { return wrapped; }, | ||
set: function (setMethod) { return originalMethod = setMethod; }, | ||
}; | ||
Object.defineProperty(target, key, dispatchDescriptor); | ||
return dispatchDescriptor; | ||
} | ||
else { | ||
originalMethod = descriptor.value; | ||
descriptor.value = wrapped; | ||
return descriptor; | ||
} | ||
}; }; | ||
} | ||
exports.dispatch = dispatch; | ||
//# sourceMappingURL=dispatch.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"dispatch":{"__symbolic":"error","message":"Function call not supported","line":9,"character":24}}},{"__symbolic":"module","version":1,"metadata":{"dispatch":{"__symbolic":"error","message":"Function call not supported","line":9,"character":24}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"dispatch":{"__symbolic":"function","parameters":[],"value":{"__symbolic":"error","message":"Function call not supported","line":10,"character":9}}}},{"__symbolic":"module","version":1,"metadata":{"dispatch":{"__symbolic":"function","parameters":[],"value":{"__symbolic":"error","message":"Function call not supported","line":10,"character":9}}}}] |
{ | ||
"name": "@angular-redux/store", | ||
"version": "6.5.0-alpha.8", | ||
"version": "6.5.0-alpha.9", | ||
"description": "Angular 2 bindings for Redux", | ||
@@ -5,0 +5,0 @@ "main": "./lib/src/index.js", |
@@ -10,29 +10,31 @@ import { NgRedux } from '../components/ng-redux'; | ||
*/ | ||
export const dispatch = () => ( | ||
target: Object, | ||
key: string | symbol | number, | ||
descriptor?: PropertyDescriptor): any => { | ||
export function dispatch(): PropertyDecorator { | ||
return function decorate( | ||
target: Object, | ||
key: string | symbol | number, | ||
descriptor?: PropertyDescriptor): PropertyDescriptor { | ||
let originalMethod: Function; | ||
let originalMethod: Function; | ||
const wrapped = function (this: any, ...args: any[]) { | ||
const result = originalMethod.apply(this, args); | ||
const store = getBaseStore(this) || NgRedux.instance; | ||
store.dispatch(result); | ||
return result; | ||
} | ||
const wrapped = function (this: any, ...args: any[]) { | ||
const result = originalMethod.apply(this, args); | ||
const store = getBaseStore(this) || NgRedux.instance; | ||
store.dispatch(result); | ||
return result; | ||
} | ||
descriptor = descriptor || Object.getOwnPropertyDescriptor(target, key); | ||
if (descriptor === undefined) { | ||
const dispatchDescriptor: PropertyDescriptor = { | ||
get: () => wrapped, | ||
set: (setMethod) => originalMethod = setMethod, | ||
descriptor = descriptor || Object.getOwnPropertyDescriptor(target, key); | ||
if (descriptor === undefined) { | ||
const dispatchDescriptor: PropertyDescriptor = { | ||
get: () => wrapped, | ||
set: (setMethod) => originalMethod = setMethod, | ||
} | ||
Object.defineProperty(target, key, dispatchDescriptor) | ||
return dispatchDescriptor; | ||
} else { | ||
originalMethod = descriptor.value; | ||
descriptor.value = wrapped; | ||
return descriptor; | ||
} | ||
Object.defineProperty(target, key, dispatchDescriptor) | ||
return dispatchDescriptor; | ||
} else { | ||
originalMethod = descriptor.value; | ||
descriptor.value = wrapped; | ||
return descriptor; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
192981
3450