@wendellhu/redi
Advanced tools
Comparing version 0.6.3 to 0.6.4
@@ -564,2 +564,5 @@ (function (global, factory) { | ||
} | ||
IdleValue.prototype.hasRun = function () { | ||
return this.didRun; | ||
}; | ||
IdleValue.prototype.dispose = function () { | ||
@@ -832,2 +835,3 @@ this.disposeCallback(); | ||
get: function (target, key) { | ||
var _a; | ||
if (key in target) { | ||
@@ -840,10 +844,14 @@ return target[key]; // such as toString | ||
} | ||
var val = idle_1.getValue(); | ||
var prop = val[key]; | ||
if (typeof prop !== 'function') { | ||
return prop; | ||
var hasInstantiated = idle_1.hasRun(); | ||
var thing = idle_1.getValue(); | ||
if (!hasInstantiated) { | ||
(_a = item.onInstantiation) === null || _a === void 0 ? void 0 : _a.call(item, thing); | ||
} | ||
prop = prop.bind(val); | ||
target[key] = prop; | ||
return prop; | ||
var property = thing[key]; | ||
if (typeof property !== 'function') { | ||
return property; | ||
} | ||
property = property.bind(thing); | ||
target[key] = property; | ||
return property; | ||
}, | ||
@@ -898,2 +906,3 @@ set: function (_target, key, value) { | ||
Injector.prototype.resolveFactory = function (id, item, shouldCache) { | ||
var _a; | ||
this.markNewResolution(id); | ||
@@ -912,2 +921,3 @@ var declaredDependencies = normalizeFactoryDeps(item.deps); | ||
this.markResolutionCompleted(); | ||
(_a = item === null || item === void 0 ? void 0 : item.onInstantiation) === null || _a === void 0 ? void 0 : _a.call(item, thing); | ||
return thing; | ||
@@ -914,0 +924,0 @@ }; |
@@ -10,3 +10,6 @@ import { DependencyIdentifier } from './dependencyIdentifier'; | ||
export declare function isCtor<T>(thing: unknown): thing is Ctor<T>; | ||
export interface ClassDependencyItem<T> { | ||
export interface DependencyItemHooks<T> { | ||
onInstantiation?: (instance: T) => void; | ||
} | ||
export interface ClassDependencyItem<T> extends DependencyItemHooks<T> { | ||
useClass: Ctor<T>; | ||
@@ -18,3 +21,3 @@ lazy?: boolean; | ||
export declare type FactoryDep<T> = [...FactoryDepModifier[], DependencyIdentifier<T>] | DependencyIdentifier<T>; | ||
export interface FactoryDependencyItem<T> { | ||
export interface FactoryDependencyItem<T> extends DependencyItemHooks<T> { | ||
useFactory: (...deps: any[]) => T; | ||
@@ -25,7 +28,7 @@ dynamic?: true; | ||
export declare function isFactoryDependencyItem<T>(thing: unknown): thing is FactoryDependencyItem<T>; | ||
export interface ValueDependencyItem<T> { | ||
export interface ValueDependencyItem<T> extends DependencyItemHooks<T> { | ||
useValue: T; | ||
} | ||
export declare function isValueDependencyItem<T>(thing: unknown): thing is ValueDependencyItem<T>; | ||
export interface AsyncDependencyItem<T> { | ||
export interface AsyncDependencyItem<T> extends DependencyItemHooks<T> { | ||
useAsync: () => Promise<T | Ctor<T> | [DependencyIdentifier<T>, SyncDependencyItem<T>]>; | ||
@@ -32,0 +35,0 @@ } |
@@ -24,4 +24,5 @@ import { Disposable } from './dispose'; | ||
constructor(executor: () => T); | ||
hasRun(): boolean; | ||
dispose(): void; | ||
getValue(): T; | ||
} |
@@ -64,2 +64,5 @@ /** | ||
} | ||
IdleValue.prototype.hasRun = function () { | ||
return this.didRun; | ||
}; | ||
IdleValue.prototype.dispose = function () { | ||
@@ -66,0 +69,0 @@ this.disposeCallback(); |
@@ -215,2 +215,3 @@ var __extends = (this && this.__extends) || (function () { | ||
get: function (target, key) { | ||
var _a; | ||
if (key in target) { | ||
@@ -223,10 +224,14 @@ return target[key]; // such as toString | ||
} | ||
var val = idle_1.getValue(); | ||
var prop = val[key]; | ||
if (typeof prop !== 'function') { | ||
return prop; | ||
var hasInstantiated = idle_1.hasRun(); | ||
var thing = idle_1.getValue(); | ||
if (!hasInstantiated) { | ||
(_a = item.onInstantiation) === null || _a === void 0 ? void 0 : _a.call(item, thing); | ||
} | ||
prop = prop.bind(val); | ||
target[key] = prop; | ||
return prop; | ||
var property = thing[key]; | ||
if (typeof property !== 'function') { | ||
return property; | ||
} | ||
property = property.bind(thing); | ||
target[key] = property; | ||
return property; | ||
}, | ||
@@ -281,2 +286,3 @@ set: function (_target, key, value) { | ||
Injector.prototype.resolveFactory = function (id, item, shouldCache) { | ||
var _a; | ||
this.markNewResolution(id); | ||
@@ -295,2 +301,3 @@ var declaredDependencies = normalizeFactoryDeps(item.deps); | ||
this.markResolutionCompleted(); | ||
(_a = item === null || item === void 0 ? void 0 : item.onInstantiation) === null || _a === void 0 ? void 0 : _a.call(item, thing); | ||
return thing; | ||
@@ -297,0 +304,0 @@ }; |
@@ -558,2 +558,5 @@ var IdentifierDecoratorSymbol = Symbol('$$IDENTIFIER_DECORATOR'); | ||
} | ||
IdleValue.prototype.hasRun = function () { | ||
return this.didRun; | ||
}; | ||
IdleValue.prototype.dispose = function () { | ||
@@ -826,2 +829,3 @@ this.disposeCallback(); | ||
get: function (target, key) { | ||
var _a; | ||
if (key in target) { | ||
@@ -834,10 +838,14 @@ return target[key]; // such as toString | ||
} | ||
var val = idle_1.getValue(); | ||
var prop = val[key]; | ||
if (typeof prop !== 'function') { | ||
return prop; | ||
var hasInstantiated = idle_1.hasRun(); | ||
var thing = idle_1.getValue(); | ||
if (!hasInstantiated) { | ||
(_a = item.onInstantiation) === null || _a === void 0 ? void 0 : _a.call(item, thing); | ||
} | ||
prop = prop.bind(val); | ||
target[key] = prop; | ||
return prop; | ||
var property = thing[key]; | ||
if (typeof property !== 'function') { | ||
return property; | ||
} | ||
property = property.bind(thing); | ||
target[key] = property; | ||
return property; | ||
}, | ||
@@ -892,2 +900,3 @@ set: function (_target, key, value) { | ||
Injector.prototype.resolveFactory = function (id, item, shouldCache) { | ||
var _a; | ||
this.markNewResolution(id); | ||
@@ -906,2 +915,3 @@ var declaredDependencies = normalizeFactoryDeps(item.deps); | ||
this.markResolutionCompleted(); | ||
(_a = item === null || item === void 0 ? void 0 : item.onInstantiation) === null || _a === void 0 ? void 0 : _a.call(item, thing); | ||
return thing; | ||
@@ -908,0 +918,0 @@ }; |
{ | ||
"$schema": "https://raw.githubusercontent.com/hullis/squirrel/master/src/schema/package.schema.json", | ||
"name": "@wendellhu/redi", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"description": "A dependency library for TypeScript and JavaScript, along with a binding for React.", | ||
@@ -6,0 +6,0 @@ "exports": { |
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
428415
4294