action-chain
Advanced tools
Comparing version 1.0.3 to 1.1.0-1537638985639
@@ -43,2 +43,3 @@ import * as tslib_1 from "tslib"; | ||
}, | ||
Constr: TestProvider, | ||
}, | ||
@@ -150,2 +151,23 @@ test: new TestProvider(), | ||
}); | ||
test('should track execution of constructor instantiation', function () { | ||
expect.assertions(3); | ||
var fn = action().test(function (_a) { | ||
var foo = _a.foo; | ||
var instance = new foo.Constr(); | ||
expect(instance.foo()).toBe('bar'); | ||
expect(instance).toBeInstanceOf(TestProvider); | ||
}); | ||
actionChain.once('effect', function (task) { | ||
expect(task).toEqual({ | ||
operatorId: 0, | ||
actionId: 0, | ||
executionId: 0, | ||
method: 'Constr', | ||
args: [], | ||
name: 'foo', | ||
result: '[Constr]', | ||
}); | ||
}); | ||
fn(); | ||
}); | ||
}); | ||
@@ -152,0 +174,0 @@ describe('ACTION CHAIN', function () { |
@@ -5,6 +5,7 @@ export var doNotProxy = Symbol('doNotProxy'); | ||
} | ||
var hasWarnedConstructor = false; | ||
function createProxyGetHandler(path, cb) { | ||
return function (target, prop) { | ||
if (typeof target[prop] === 'function') { | ||
return function () { | ||
var func = function () { | ||
var args = []; | ||
@@ -37,2 +38,19 @@ for (var _i = 0; _i < arguments.length; _i++) { | ||
}; | ||
return new Proxy(func, { | ||
construct: function (_, args) { | ||
var _a; | ||
// eslint-disable-next-line | ||
cb({ | ||
name: path, | ||
method: prop, | ||
args: args, | ||
result: "[" + prop.toString() + "]", | ||
}); | ||
if (!hasWarnedConstructor) { | ||
console.warn("EFFECTS - It is highly recommended to create a custom effect, exposing a method that deals with the instantiation of \"" + path + "." + prop.toString() + "\". It improves readability and debugability of your app"); | ||
hasWarnedConstructor = true; | ||
} | ||
return new ((_a = target[prop]).bind.apply(_a, [void 0].concat(args)))(); | ||
}, | ||
}); | ||
} | ||
@@ -39,0 +57,0 @@ if (isObject(target[prop])) { |
@@ -45,2 +45,3 @@ "use strict"; | ||
}, | ||
Constr: TestProvider, | ||
}, | ||
@@ -152,2 +153,23 @@ test: new TestProvider(), | ||
}); | ||
test('should track execution of constructor instantiation', function () { | ||
expect.assertions(3); | ||
var fn = action().test(function (_a) { | ||
var foo = _a.foo; | ||
var instance = new foo.Constr(); | ||
expect(instance.foo()).toBe('bar'); | ||
expect(instance).toBeInstanceOf(TestProvider); | ||
}); | ||
actionChain.once('effect', function (task) { | ||
expect(task).toEqual({ | ||
operatorId: 0, | ||
actionId: 0, | ||
executionId: 0, | ||
method: 'Constr', | ||
args: [], | ||
name: 'foo', | ||
result: '[Constr]', | ||
}); | ||
}); | ||
fn(); | ||
}); | ||
}); | ||
@@ -154,0 +176,0 @@ describe('ACTION CHAIN', function () { |
@@ -7,6 +7,7 @@ "use strict"; | ||
} | ||
var hasWarnedConstructor = false; | ||
function createProxyGetHandler(path, cb) { | ||
return function (target, prop) { | ||
if (typeof target[prop] === 'function') { | ||
return function () { | ||
var func = function () { | ||
var args = []; | ||
@@ -39,2 +40,19 @@ for (var _i = 0; _i < arguments.length; _i++) { | ||
}; | ||
return new Proxy(func, { | ||
construct: function (_, args) { | ||
var _a; | ||
// eslint-disable-next-line | ||
cb({ | ||
name: path, | ||
method: prop, | ||
args: args, | ||
result: "[" + prop.toString() + "]", | ||
}); | ||
if (!hasWarnedConstructor) { | ||
console.warn("EFFECTS - It is highly recommended to create a custom effect, exposing a method that deals with the instantiation of \"" + path + "." + prop.toString() + "\". It improves readability and debugability of your app"); | ||
hasWarnedConstructor = true; | ||
} | ||
return new ((_a = target[prop]).bind.apply(_a, [void 0].concat(args)))(); | ||
}, | ||
}); | ||
} | ||
@@ -41,0 +59,0 @@ if (isObject(target[prop])) { |
{ | ||
"name": "action-chain", | ||
"version": "1.0.3", | ||
"version": "1.1.0-1537638985639", | ||
"description": "Functional actions", | ||
@@ -34,5 +34,5 @@ "author": "Christian Alfoni <christianalfoni@gmail.com>", | ||
"tslib": "^1.9.3", | ||
"betsy": "1.0.1" | ||
"betsy": "1.0.1-1537638985639" | ||
}, | ||
"devDependencies": {} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
119829
1225
2
+ Addedbetsy@1.0.1-1537638985639(transitive)
- Removedbetsy@1.0.1(transitive)
Updatedbetsy@1.0.1-1537638985639