API Reference
@univerjs
@univerjs/core
classes
Univerinstanceservice

@univerjs/core v0.4.2Docs


Class: UniverInstanceService

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.

Extends

Implements

Constructors

new UniverInstanceService()

new UniverInstanceService(_injector, _contextService): UniverInstanceService

Parameters

ParameterType
_injectorInjector
_contextServiceIContextService

Returns

UniverInstanceService

Overrides

Disposable.constructor

Defined in

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

Properties

PropertyModifierTypeDefault valueDescriptionInherited fromDefined in
_disposedprotectedbooleanfalse-Disposable._disposedsubmodules/univer/packages/core/src/shared/lifecycle.ts:93 (opens in a new tab)
currentUnits$readonlyObservable<Map<number, Nullable<UnitModel<object, number>>>>undefined--submodules/univer/packages/core/src/services/instance/instance.service.ts:142 (opens in a new tab)
focused$readonlyObservable<Nullable<string>>undefinedAn observable value that emits the id of the focused unit.-submodules/univer/packages/core/src/services/instance/instance.service.ts:234 (opens in a new tab)
unitAdded$readonlyObservable<UnitModel<object, number>>undefinedOmits value when a new UnitModel is created.-submodules/univer/packages/core/src/services/instance/instance.service.ts:160 (opens in a new tab)
unitDisposed$readonlyObservable<UnitModel<object, number>>undefinedOmits value when a UnitModel is disposed.-submodules/univer/packages/core/src/services/instance/instance.service.ts:194 (opens in a new tab)

Accessors

focused

get focused(): Nullable<UnitModel<object, number>>

Returns

Nullable<UnitModel<object, number>>

Defined in

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

Methods

__setCreateHandler()

__setCreateHandler(handler): void

Parameters

ParameterType
handler(type, data, ctor, options?) => UnitModel<object, number>

Returns

void

Defined in

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


changeDoc()

changeDoc(unitId, doc): void

Parameters

ParameterType
unitIdstring
docDocumentDataModel

Returns

void

Deprecated

Implementation of

IUniverInstanceService.changeDoc

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:221 (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
dataT
options?ICreateUnitOptions

Returns

U

Implementation of

IUniverInstanceService.createUnit

Defined in

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


dispose()

dispose(): void

Returns

void

Overrides

Disposable.dispose

Defined in

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


disposeUnit()

disposeUnit(unitId): boolean

Dispose a unit

Parameters

ParameterType
unitIdstring

Returns

boolean

Implementation of

IUniverInstanceService.disposeUnit

Defined in

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


disposeWithMe()

disposeWithMe(disposable): IDisposable

Parameters

ParameterType
disposableDisposableLike

Returns

IDisposable

Inherited from

Disposable.disposeWithMe

Defined in

submodules/univer/packages/core/src/shared/lifecycle.ts:96 (opens in a new tab)


ensureNotDisposed()

protected ensureNotDisposed(): void

Returns

void

Inherited from

Disposable.ensureNotDisposed

Defined in

submodules/univer/packages/core/src/shared/lifecycle.ts:100 (opens in a new tab)


focusUnit()

focusUnit(id): void

Focus a unit.

Parameters

ParameterType
idnull | string

Returns

void

Implementation of

IUniverInstanceService.focusUnit

Defined in

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


getAllUnitsForType()

getAllUnitsForType<T>(type): T[]

Type Parameters

Type Parameter
T

Parameters

ParameterType
typenumber

Returns

T[]

Implementation of

IUniverInstanceService.getAllUnitsForType

Defined in

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


getCurrentTypeOfUnit$()

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

Type Parameters

Type Parameter
T

Parameters

ParameterType
typenumber

Returns

Observable<Nullable<T>>

Implementation of

IUniverInstanceService.getCurrentTypeOfUnit$

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:143 (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>

Implementation of

IUniverInstanceService.getCurrentUnitForType

Defined in

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


getCurrentUniverDocInstance()

getCurrentUniverDocInstance(): Nullable<DocumentDataModel>

Returns

Nullable<DocumentDataModel>

Deprecated

Implementation of

IUniverInstanceService.getCurrentUniverDocInstance

Defined in

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


getFocusedUnit()

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

Returns

Nullable<UnitModel<object, number>>

Implementation of

IUniverInstanceService.getFocusedUnit

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:271 (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>

Implementation of

IUniverInstanceService.getTypeOfUnitAdded$

Defined in

submodules/univer/packages/core/src/services/instance/instance.service.ts:161 (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
typeUniverInstanceType

Returns

Observable<T>

Implementation of

IUniverInstanceService.getTypeOfUnitDisposed$

Defined in

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


getUnit()

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

Type Parameters

Type ParameterDefault type
T extends UnitModel<object, number>UnitModel<object, number>

Parameters

ParameterType
idstring
type?number

Returns

Nullable<T>

Implementation of

IUniverInstanceService.getUnit

Defined in

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


getUnitType()

getUnitType(unitId): UniverInstanceType

Parameters

ParameterType
unitIdstring

Returns

UniverInstanceType

Implementation of

IUniverInstanceService.getUnitType

Defined in

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


getUniverDocInstance()

getUniverDocInstance(unitId): Nullable<DocumentDataModel>

Parameters

ParameterType
unitIdstring

Returns

Nullable<DocumentDataModel>

Deprecated

Implementation of

IUniverInstanceService.getUniverDocInstance

Defined in

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


getUniverSheetInstance()

getUniverSheetInstance(unitId): Nullable<Workbook>

Parameters

ParameterType
unitIdstring

Returns

Nullable<Workbook>

Deprecated

Implementation of

IUniverInstanceService.getUniverSheetInstance

Defined in

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


registerCtorForType()

registerCtorForType<T>(type, ctor): IDisposable

Type Parameters

Type Parameter
T extends UnitModel<object, number>

Parameters

ParameterType
typenumber
ctor() => T

Returns

IDisposable

Implementation of

IUniverInstanceService.registerCtorForType

Defined in

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


setCurrentUnitForType()

setCurrentUnitForType(unitId): void

Parameters

ParameterType
unitIdstring

Returns

void

Implementation of

IUniverInstanceService.setCurrentUnitForType

Defined in

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


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