API Reference
@univerjs
@univerjs/sheets-thread-comment
classes
Injector

@univerjs/sheets-thread-comment v0.1.17Docs


Class: Injector

Constructors

new Injector()

new Injector(dependencies?, parent?): Injector

Create a new Injector instance

Parameters

ParameterTypeDescription
dependencies?Dependency[]Dependencies that should be resolved by this injector instance.
parent?null | InjectorOptional parent injector.

Returns

Injector

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:22

Methods

add()

add<T>(dependency): void

Add a dependency or its instance into injector. It would throw an error if the dependency has already been instantiated.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
dependencyDependencyOrInstance<T>The dependency or an instance that would be add in the injector.

Returns

void

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:40


createChild()

createChild(dependencies?): Injector

Create a child inject with a set of dependencies.

Parameters

ParameterTypeDescription
dependencies?Dependency[]Dependencies that should be resolved by the newly created child injector.

Returns

Injector

The child injector.

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:28


createInstance()

createInstance<T, U, C>(ctor, ...customArgs): C

Instantiate a class. The created instance would not be held by the injector.

Type Parameters

Type Parameter
T extends unknown[]
U extends unknown[]
C

Parameters

ParameterType
ctor(...args) => C
...customArgsT

Returns

C

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:84


delete()

delete<T>(identifier): void

Delete a dependency from an injector. It would throw an error when the deleted dependency has already been instantiated.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
identifierDependencyIdentifier<T>The identifier of the dependency that is supposed to be deleted.

Returns

void

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:54


dispose()

dispose(): void

Dispose the injector and all dependencies held by this injector. Note that its child injectors will dispose first.

Returns

void

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:32


get()

get(id, lookUp)

get<T>(id, lookUp?): T
Type Parameters
Type Parameter
T
Parameters
ParameterType
idDependencyIdentifier<T>
lookUp?LookUp
Returns

T

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:70

get(id, quantity, lookUp)

get<T>(
   id, 
   quantity, 
   lookUp?): T[]
Type Parameters
Type Parameter
T
Parameters
ParameterType
idDependencyIdentifier<T>
quantityMANY
lookUp?LookUp
Returns

T[]

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:71

get(id, quantity, lookUp)

get<T>(
   id, 
   quantity, 
   lookUp?): null | T
Type Parameters
Type Parameter
T
Parameters
ParameterType
idDependencyIdentifier<T>
quantityOPTIONAL
lookUp?LookUp
Returns

null | T

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:72

get(id, quantity, lookUp)

get<T>(
   id, 
   quantity, 
   lookUp?): T
Type Parameters
Type Parameter
T
Parameters
ParameterType
idDependencyIdentifier<T>
quantityREQUIRED
lookUp?LookUp
Returns

T

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:73

get(id, quantity, lookUp)

get<T>(
   id, 
   quantity?, 
   lookUp?): null | T | T[]
Type Parameters
Type Parameter
T
Parameters
ParameterType
idDependencyIdentifier<T>
quantity?Quantity
lookUp?LookUp
Returns

null | T | T[]

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:74

get(id, quantityOrLookup, lookUp)

get<T>(
   id, 
   quantityOrLookup?, 
   lookUp?): null | T | T[]
Type Parameters
Type Parameter
T
Parameters
ParameterType
idDependencyIdentifier<T>
quantityOrLookup?Quantity | LookUp
lookUp?LookUp
Returns

null | T | T[]

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:75


getAsync()

getAsync<T>(id): Promise<T>

Get a dependency in the async way.

Type Parameters

Type Parameter
T

Parameters

ParameterType
idDependencyIdentifier<T>

Returns

Promise<T>

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:80


has()

has<T>(id): boolean

Check if the injector could initialize a dependency.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
idDependencyIdentifier<T>Identifier of the dependency

Returns

boolean

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:69


invoke()

invoke<T, P>(cb, ...args): T

Invoke a function with dependencies injected. The function could only get dependency from the injector and other methods are not accessible for the function.

Type Parameters

Type ParameterDefault type
T-
P extends any[][]

Parameters

ParameterTypeDescription
cb(accessor, ...args) => Tthe function to be executed
...argsParguments to be passed into the function

Returns

T

the return value of the function

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:63


replace()

replace<T>(dependency): void

Replace an injection mapping for interface-based injection. It would throw an error if the dependency has already been instantiated.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
dependencyDependency<T>The dependency that will replace the already existed dependency.

Returns

void

Defined in

node_modules/.pnpm/@wendellhu+redi@0.15.4/node_modules/@wendellhu/redi/esm/injector.d.ts:47


Copyright © 2021-2024 DreamNum Co,Ltd. All Rights Reserved.