@univerjscoreclassesUniverinstanceservice

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


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

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

Properties

PropertyModifierTypeDefault valueDescriptionInherited fromDefined in
_disposedprotectedbooleanfalse-Disposable._disposedpackages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:93
currentUnits$readonlyObservable<Map<number, Nullable<UnitModel<object, number>>>>undefined--packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:142
focused$readonlyObservable<Nullable<string>>undefinedAn 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:234
unitAdded$readonlyObservable<UnitModel<object, number>>undefinedOmits value when a new UnitModel is created.-packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:160
unitDisposed$readonlyObservable<UnitModel<object, number>>undefinedOmits value when a UnitModel is disposed.-packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/instance/instance.service.ts:194

Accessors

focused

Get Signature

get focused(): 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:235

Methods

__setCreateHandler()

__setCreateHandler(handler): void

Parameters

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

Returns

void

Defined in

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


changeDoc()

changeDoc(unitId, doc): void

Parameters

ParameterType
unitIdstring
docDocumentDataModel

Returns

void

Deprecated

Implementation of

IUniverInstanceService.changeDoc

Defined in

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


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

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


dispose()

dispose(): void

Returns

void

Overrides

Disposable.dispose

Defined in

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


disposeUnit()

disposeUnit(unitId): boolean

Dispose a unit

Parameters

ParameterType
unitIdstring

Returns

boolean

Implementation of

IUniverInstanceService.disposeUnit

Defined in

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


disposeWithMe()

disposeWithMe(disposable): IDisposable

Parameters

ParameterType
disposableDisposableLike

Returns

IDisposable

Inherited from

Disposable.disposeWithMe

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:96


ensureNotDisposed()

protected ensureNotDisposed(): void

Returns

void

Inherited from

Disposable.ensureNotDisposed

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:100


focusUnit()

focusUnit(id): void

Focus a unit.

Parameters

ParameterType
idnull | string

Returns

void

Implementation of

IUniverInstanceService.focusUnit

Defined in

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


getAllUnitsForType()

getAllUnitsForType<T>(type): T[]

Type Parameters

Type Parameter
T

Parameters

ParameterType
typenumber

Returns

T[]

Implementation of

IUniverInstanceService.getAllUnitsForType

Defined in

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


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

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


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

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


getCurrentUniverDocInstance()

getCurrentUniverDocInstance(): Nullable<DocumentDataModel>

Returns

Nullable<DocumentDataModel>

Deprecated

Implementation of

IUniverInstanceService.getCurrentUniverDocInstance

Defined in

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


getFocusedUnit()

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

Returns

Nullable<UnitModel<object, number>>

Implementation of

IUniverInstanceService.getFocusedUnit

Defined in

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


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

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


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

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


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

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


getUnitType()

getUnitType(unitId): UniverInstanceType

Parameters

ParameterType
unitIdstring

Returns

UniverInstanceType

Implementation of

IUniverInstanceService.getUnitType

Defined in

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


getUniverDocInstance()

getUniverDocInstance(unitId): Nullable<DocumentDataModel>

Parameters

ParameterType
unitIdstring

Returns

Nullable<DocumentDataModel>

Deprecated

Implementation of

IUniverInstanceService.getUniverDocInstance

Defined in

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


getUniverSheetInstance()

getUniverSheetInstance(unitId): Nullable<Workbook>

Parameters

ParameterType
unitIdstring

Returns

Nullable<Workbook>

Deprecated

Implementation of

IUniverInstanceService.getUniverSheetInstance

Defined in

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


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

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


setCurrentUnitForType()

setCurrentUnitForType(unitId): void

Parameters

ParameterType
unitIdstring

Returns

void

Implementation of

IUniverInstanceService.setCurrentUnitForType

Defined in

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