@wendellhu/redi
Advanced tools
Comparing version 0.15.2 to 0.15.4
@@ -79,3 +79,3 @@ (function (global, factory) { | ||
var injector = useInjector(); | ||
return injector.get(id, quantityOrLookUp, lookUp); | ||
return React__namespace.useMemo(function () { return injector.get(id, quantityOrLookUp, lookUp); }, [id, quantityOrLookUp, lookUp]); | ||
} | ||
@@ -82,0 +82,0 @@ |
@@ -319,9 +319,6 @@ (function (global, factory) { | ||
function DependencyNotFoundForModuleError(toInstantiate, id, index) { | ||
var _this = this; | ||
var msg = "Cannot find \"".concat(prettyPrintIdentifier(id), "\" registered by any injector. It is the ").concat(index, "th param of \"").concat(isIdentifierDecorator(toInstantiate) | ||
? prettyPrintIdentifier(toInstantiate) | ||
: toInstantiate.name, "\". The stack of dependencies is: \"").concat(ResolvingStack.map(function (id) { return prettyPrintIdentifier(id); }).join(' -> '), "\"."); | ||
_this = _super.call(this, msg) || this; | ||
clearResolvingStack(); | ||
return _this; | ||
: toInstantiate.name, "\"."); | ||
return _super.call(this, msg) || this; | ||
} | ||
@@ -333,4 +330,7 @@ return DependencyNotFoundForModuleError; | ||
function DependencyNotFoundError(id) { | ||
var _this = this; | ||
var msg = "Cannot find \"".concat(prettyPrintIdentifier(id), "\" registered by any injector. The stack of dependencies is: \"").concat(ResolvingStack.map(function (id) { return prettyPrintIdentifier(id); }).join(' -> '), "\"."); | ||
return _super.call(this, msg) || this; | ||
_this = _super.call(this, msg) || this; | ||
clearResolvingStack(); | ||
return _this; | ||
} | ||
@@ -860,15 +860,7 @@ return DependencyNotFoundError; | ||
this._ensureInjectorNotDisposed(); | ||
try { | ||
var newResult = this._get(id, quantityOrLookup, lookUp); | ||
if ((Array.isArray(newResult) && newResult.some(function (r) { return isAsyncHook(r); })) || isAsyncHook(newResult)) { | ||
throw new GetAsyncItemFromSyncApiError(id); | ||
} | ||
return newResult; | ||
var newResult = this._get(id, quantityOrLookup, lookUp); | ||
if ((Array.isArray(newResult) && newResult.some(function (r) { return isAsyncHook(r); })) || isAsyncHook(newResult)) { | ||
throw new GetAsyncItemFromSyncApiError(id); | ||
} | ||
catch (e) { | ||
if (e instanceof DependencyNotFoundError) { | ||
clearResolvingStack(); | ||
} | ||
throw e; | ||
} | ||
return newResult; | ||
}; | ||
@@ -875,0 +867,0 @@ Injector.prototype._get = function (id, quantityOrLookup, lookUp, toSelf) { |
@@ -38,9 +38,6 @@ var __extends = (this && this.__extends) || (function () { | ||
function DependencyNotFoundForModuleError(toInstantiate, id, index) { | ||
var _this = this; | ||
var msg = "Cannot find \"".concat(prettyPrintIdentifier(id), "\" registered by any injector. It is the ").concat(index, "th param of \"").concat(isIdentifierDecorator(toInstantiate) | ||
? prettyPrintIdentifier(toInstantiate) | ||
: toInstantiate.name, "\". The stack of dependencies is: \"").concat(ResolvingStack.map(function (id) { return prettyPrintIdentifier(id); }).join(' -> '), "\"."); | ||
_this = _super.call(this, msg) || this; | ||
clearResolvingStack(); | ||
return _this; | ||
: toInstantiate.name, "\"."); | ||
return _super.call(this, msg) || this; | ||
} | ||
@@ -53,4 +50,7 @@ return DependencyNotFoundForModuleError; | ||
function DependencyNotFoundError(id) { | ||
var _this = this; | ||
var msg = "Cannot find \"".concat(prettyPrintIdentifier(id), "\" registered by any injector. The stack of dependencies is: \"").concat(ResolvingStack.map(function (id) { return prettyPrintIdentifier(id); }).join(' -> '), "\"."); | ||
return _super.call(this, msg) || this; | ||
_this = _super.call(this, msg) || this; | ||
clearResolvingStack(); | ||
return _this; | ||
} | ||
@@ -57,0 +57,0 @@ return DependencyNotFoundError; |
@@ -37,3 +37,3 @@ var __extends = (this && this.__extends) || (function () { | ||
import { getDependencies } from './decorators'; | ||
import { DependencyCollection, DependencyNotFoundError, DependencyNotFoundForModuleError, ResolvedDependencyCollection, clearResolvingStack, popupResolvingStack, pushResolvingStack, } from './dependencyCollection'; | ||
import { DependencyCollection, DependencyNotFoundError, DependencyNotFoundForModuleError, ResolvedDependencyCollection, popupResolvingStack, pushResolvingStack, } from './dependencyCollection'; | ||
import { normalizeFactoryDeps } from './dependencyDescriptor'; | ||
@@ -242,15 +242,7 @@ import { normalizeForwardRef } from './dependencyForwardRef'; | ||
this._ensureInjectorNotDisposed(); | ||
try { | ||
var newResult = this._get(id, quantityOrLookup, lookUp); | ||
if ((Array.isArray(newResult) && newResult.some(function (r) { return isAsyncHook(r); })) || isAsyncHook(newResult)) { | ||
throw new GetAsyncItemFromSyncApiError(id); | ||
} | ||
return newResult; | ||
var newResult = this._get(id, quantityOrLookup, lookUp); | ||
if ((Array.isArray(newResult) && newResult.some(function (r) { return isAsyncHook(r); })) || isAsyncHook(newResult)) { | ||
throw new GetAsyncItemFromSyncApiError(id); | ||
} | ||
catch (e) { | ||
if (e instanceof DependencyNotFoundError) { | ||
clearResolvingStack(); | ||
} | ||
throw e; | ||
} | ||
return newResult; | ||
}; | ||
@@ -257,0 +249,0 @@ Injector.prototype._get = function (id, quantityOrLookup, lookUp, toSelf) { |
@@ -35,4 +35,4 @@ var __extends = (this && this.__extends) || (function () { | ||
var injector = useInjector(); | ||
return injector.get(id, quantityOrLookUp, lookUp); | ||
return React.useMemo(function () { return injector.get(id, quantityOrLookUp, lookUp); }, [id, quantityOrLookUp, lookUp]); | ||
} | ||
//# sourceMappingURL=reactHooks.js.map |
@@ -55,3 +55,3 @@ import * as React from 'react'; | ||
var injector = useInjector(); | ||
return injector.get(id, quantityOrLookUp, lookUp); | ||
return React.useMemo(function () { return injector.get(id, quantityOrLookUp, lookUp); }, [id, quantityOrLookUp, lookUp]); | ||
} | ||
@@ -58,0 +58,0 @@ |
@@ -313,9 +313,6 @@ var IdentifierDecoratorSymbol = Symbol('$$IDENTIFIER_DECORATOR'); | ||
function DependencyNotFoundForModuleError(toInstantiate, id, index) { | ||
var _this = this; | ||
var msg = "Cannot find \"".concat(prettyPrintIdentifier(id), "\" registered by any injector. It is the ").concat(index, "th param of \"").concat(isIdentifierDecorator(toInstantiate) | ||
? prettyPrintIdentifier(toInstantiate) | ||
: toInstantiate.name, "\". The stack of dependencies is: \"").concat(ResolvingStack.map(function (id) { return prettyPrintIdentifier(id); }).join(' -> '), "\"."); | ||
_this = _super.call(this, msg) || this; | ||
clearResolvingStack(); | ||
return _this; | ||
: toInstantiate.name, "\"."); | ||
return _super.call(this, msg) || this; | ||
} | ||
@@ -327,4 +324,7 @@ return DependencyNotFoundForModuleError; | ||
function DependencyNotFoundError(id) { | ||
var _this = this; | ||
var msg = "Cannot find \"".concat(prettyPrintIdentifier(id), "\" registered by any injector. The stack of dependencies is: \"").concat(ResolvingStack.map(function (id) { return prettyPrintIdentifier(id); }).join(' -> '), "\"."); | ||
return _super.call(this, msg) || this; | ||
_this = _super.call(this, msg) || this; | ||
clearResolvingStack(); | ||
return _this; | ||
} | ||
@@ -854,15 +854,7 @@ return DependencyNotFoundError; | ||
this._ensureInjectorNotDisposed(); | ||
try { | ||
var newResult = this._get(id, quantityOrLookup, lookUp); | ||
if ((Array.isArray(newResult) && newResult.some(function (r) { return isAsyncHook(r); })) || isAsyncHook(newResult)) { | ||
throw new GetAsyncItemFromSyncApiError(id); | ||
} | ||
return newResult; | ||
var newResult = this._get(id, quantityOrLookup, lookUp); | ||
if ((Array.isArray(newResult) && newResult.some(function (r) { return isAsyncHook(r); })) || isAsyncHook(newResult)) { | ||
throw new GetAsyncItemFromSyncApiError(id); | ||
} | ||
catch (e) { | ||
if (e instanceof DependencyNotFoundError) { | ||
clearResolvingStack(); | ||
} | ||
throw e; | ||
} | ||
return newResult; | ||
}; | ||
@@ -869,0 +861,0 @@ Injector.prototype._get = function (id, quantityOrLookup, lookUp, toSelf) { |
{ | ||
"$schema": "https://raw.githubusercontent.com/wzhudev/squirrel/master/src/schema/package.schema.json", | ||
"name": "@wendellhu/redi", | ||
"version": "0.15.2", | ||
"version": "0.15.4", | ||
"description": "A dependency library for TypeScript and JavaScript, along with a binding for React.", | ||
@@ -6,0 +6,0 @@ "author": "Wenzhao Hu<wzhudev@gmail.com>", |
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
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
495163
4990