API Reference
@univerjs
@univerjs/core
interfaces
Iuniverinstanceservice

@univerjs/core v0.4.2Docs


Interface: IUniverInstanceService

IUniverInstanceService holds all the current univer instances and provides a set of methods to add and remove univer instances.

It also manages the focused univer instance.

Properties

PropertyTypeDescriptionDefined in
focused$Observable<Nullable<string>>An observable value that emits the id of the focused unit.submodules/univer/packages/core/src/services/instance/instance.service.ts:64 (opens in a new tab)
unitAdded$Observable<UnitModel<object, number>>Omits value when a new UnitModel is created.submodules/univer/packages/core/src/services/instance/instance.service.ts:51 (opens in a new tab)
unitDisposed$Observable<UnitModel<object, number>>Omits value when a UnitModel is disposed.submodules/univer/packages/core/src/services/instance/instance.service.ts:59 (opens in a new tab)

Methods

changeDoc()

changeDoc(unitId, doc): void

Parameters

ParameterType
unitIdstring
docDocumentDataModel

Returns

void

Deprecated

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:82 (opens in a new tab)


createUnit()

createUnit<T, U>(
   type, 
   data, 
   options?): U

Create a unit with snapshot info.

Type Parameters

Type Parameter
T
U extends UnitModel<object, number>

Parameters

ParameterType
typenumber
dataPartial<T>
options?ICreateUnitOptions

Returns

U

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:75 (opens in a new tab)


disposeUnit()

disposeUnit(unitId): boolean

Dispose a unit

Parameters

ParameterType
unitIdstring

Returns

boolean

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:77 (opens in a new tab)


focusUnit()

focusUnit(unitId): void

Focus a unit.

Parameters

ParameterType
unitIdnull | string

Returns

void

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:66 (opens in a new tab)


getAllUnitsForType()

getAllUnitsForType<T>(type): T[]

Type Parameters

Type Parameter
T

Parameters

ParameterType
typenumber

Returns

T[]

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:85 (opens in a new tab)


getCurrentTypeOfUnit$()

getCurrentTypeOfUnit$<T>(type): Observable<Nullable<T>>

Type Parameters

Type Parameter
T extends UnitModel<object, number>

Parameters

ParameterType
typenumber

Returns

Observable<Nullable<T>>

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:72 (opens in a new tab)


getCurrentUnitForType()

getCurrentUnitForType<T>(type): Nullable<T>

Type Parameters

Type Parameter
T extends UnitModel<object, number>

Parameters

ParameterType
typenumber

Returns

Nullable<T>

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:69 (opens in a new tab)


getCurrentUniverDocInstance()

getCurrentUniverDocInstance(): Nullable<DocumentDataModel>

Returns

Nullable<DocumentDataModel>

Deprecated

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:93 (opens in a new tab)


getFocusedUnit()

getFocusedUnit(): Nullable<UnitModel<object, number>>

Returns

Nullable<UnitModel<object, number>>

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:67 (opens in a new tab)


getTypeOfUnitAdded$()

getTypeOfUnitAdded$<T>(type): Observable<T>

Subscribe to curtain type of units' creation.

Type Parameters

Type Parameter
T extends UnitModel<object, number>

Parameters

ParameterType
typenumber

Returns

Observable<T>

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:53 (opens in a new tab)


getTypeOfUnitDisposed$()

getTypeOfUnitDisposed$<T>(type): Observable<T>

Subscribe to curtain type of units' disposing.

Type Parameters

Type Parameter
T extends UnitModel<object, number>

Parameters

ParameterType
typenumber

Returns

Observable<T>

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:61 (opens in a new tab)


getUnit()

getUnit<T>(id, type?): Nullable<T>

Type Parameters

Type Parameter
T extends UnitModel<object, number>

Parameters

ParameterType
idstring
type?number

Returns

Nullable<T>

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:84 (opens in a new tab)


getUnitType()

getUnitType(unitId): number

Parameters

ParameterType
unitIdstring

Returns

number

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:86 (opens in a new tab)


getUniverDocInstance()

getUniverDocInstance(unitId): Nullable<DocumentDataModel>

Parameters

ParameterType
unitIdstring

Returns

Nullable<DocumentDataModel>

Deprecated

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:91 (opens in a new tab)


getUniverSheetInstance()

getUniverSheetInstance(unitId): Nullable<Workbook>

Parameters

ParameterType
unitIdstring

Returns

Nullable<Workbook>

Deprecated

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:89 (opens in a new tab)


registerCtorForType()

registerCtorForType<T>(type, ctor): IDisposable

Type Parameters

Type Parameter
T extends UnitModel<object, number>

Parameters

ParameterType
typenumber
ctor(...args) => T

Returns

IDisposable

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:79 (opens in a new tab)


setCurrentUnitForType()

setCurrentUnitForType(unitId): void

Parameters

ParameterType
unitIdstring

Returns

void

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:70 (opens in a new tab)


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