@univerjscoreinterfacesIuniverinstanceservice

@univerjs/core v0.5.0-beta.1Docs


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.packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:64
unitAdded$Observable<UnitModel<object, number>>Omits value when a new UnitModel is created.packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:51
unitDisposed$Observable<UnitModel<object, number>>Omits value when a UnitModel is disposed.packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:59

Methods

changeDoc()

changeDoc(unitId, doc): void

Parameters

ParameterType
unitIdstring
docDocumentDataModel

Returns

void

Deprecated

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:82


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

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:75


disposeUnit()

disposeUnit(unitId): boolean

Dispose a unit

Parameters

ParameterType
unitIdstring

Returns

boolean

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:77


focusUnit()

focusUnit(unitId): void

Focus a unit.

Parameters

ParameterType
unitIdnull | string

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:66


getAllUnitsForType()

getAllUnitsForType<T>(type): T[]

Type Parameters

Type Parameter
T

Parameters

ParameterType
typenumber

Returns

T[]

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:85


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

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:72


getCurrentUnitForType()

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

Type Parameters

Type Parameter
T extends UnitModel<object, number>

Parameters

ParameterType
typenumber

Returns

Nullable<T>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:69


getCurrentUniverDocInstance()

getCurrentUniverDocInstance(): Nullable<DocumentDataModel>

Returns

Nullable<DocumentDataModel>

Deprecated

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:93


getFocusedUnit()

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

Returns

Nullable<UnitModel<object, number>>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:67


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

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:53


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

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:61


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

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:84


getUnitType()

getUnitType(unitId): number

Parameters

ParameterType
unitIdstring

Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:86


getUniverDocInstance()

getUniverDocInstance(unitId): Nullable<DocumentDataModel>

Parameters

ParameterType
unitIdstring

Returns

Nullable<DocumentDataModel>

Deprecated

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:91


getUniverSheetInstance()

getUniverSheetInstance(unitId): Nullable<Workbook>

Parameters

ParameterType
unitIdstring

Returns

Nullable<Workbook>

Deprecated

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:89


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

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:79


setCurrentUnitForType()

setCurrentUnitForType(unitId): void

Parameters

ParameterType
unitIdstring

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:70