Skip to content

Class: ExtensionStore<T>#

Common.Store.ExtensionStore

Type parameters#

Name
T

Hierarchy#

  • BaseStore<T>

ExtensionStore

Table of contents#

Constructors#

Properties#

Accessors#

Methods#

Constructors#

constructor#

Protected new ExtensionStore<T>(params)

Type parameters#

Name
T

Parameters#

Name Type
params BaseStoreParams<T>

Inherited from#

BaseStore<T>.constructor

Properties#

displayName#

Readonly displayName: "ExtensionStore<T>"

Overrides#

BaseStore.displayName


extension#

Protected Optional extension: LensExtension<LensExtensionDependencies>


params#

Protected params: BaseStoreParams<T>

Inherited from#

BaseStore.params


storeConfig#

Protected Optional storeConfig: Conf<T>

Inherited from#

BaseStore.storeConfig


syncDisposers#

Protected syncDisposers: Disposer[] = []

Inherited from#

BaseStore.syncDisposers

Accessors#

name#

get name(): string

Returns#

string

Inherited from#

BaseStore.name


path#

get path(): string

Returns#

string

Inherited from#

BaseStore.path


syncMainChannel#

Protected get syncMainChannel(): string

Returns#

string

Inherited from#

BaseStore.syncMainChannel


syncRendererChannel#

Protected get syncRendererChannel(): string

Returns#

string

Inherited from#

BaseStore.syncRendererChannel

Methods#

applyWithoutSync#

Protected applyWithoutSync(callback): void

Parameters#

Name Type
callback () => void

Returns#

void

Inherited from#

BaseStore.applyWithoutSync


cwd#

Protected cwd(): string

Returns#

string

Overrides#

BaseStore.cwd


disableSync#

disableSync(): void

Returns#

void

Inherited from#

BaseStore.disableSync


enableSync#

enableSync(): void

Returns#

void

Inherited from#

BaseStore.enableSync


fromStore#

Protected Abstract fromStore(data): void

fromStore is called internally when a child class syncs with the file system.

Note: This function must be synchronous.

Parameters#

Name Type Description
data T the parsed information read from the stored JSON file

Returns#

void

Inherited from#

BaseStore.fromStore


load#

load(): void

Returns#

void

Overrides#

BaseStore.load


loadExtension#

loadExtension(extension): void

Parameters#

Name Type
extension LensExtension<LensExtensionDependencies>

Returns#

void


onModelChange#

Protected onModelChange(model): void

Parameters#

Name Type
model T

Returns#

void

Inherited from#

BaseStore.onModelChange


onSync#

Protected onSync(model): void

Parameters#

Name Type
model T

Returns#

void

Inherited from#

BaseStore.onSync


onSyncFromMain#

Protected onSyncFromMain(model): void

Parameters#

Name Type
model T

Returns#

void

Inherited from#

BaseStore.onSyncFromMain


saveToFile#

Protected saveToFile(model): void

Parameters#

Name Type
model T

Returns#

void

Inherited from#

BaseStore.saveToFile


toJSON#

Abstract toJSON(): T

toJSON is called when syncing the store to the filesystem. It should produce a JSON serializable object representation of the current state.

It is recommended that a round trip is valid. Namely, calling this.fromStore(this.toJSON()) shouldn't change the state.

Returns#

T

Inherited from#

BaseStore.toJSON


unregisterIpcListener#

unregisterIpcListener(): void

Returns#

void

Inherited from#

BaseStore.unregisterIpcListener


createInstance#

Static createInstance<T, R>(this, ...args): T

Creates the single instance of the child class if one was not already created.

Multiple calls will return the same instance. Essentially throwing away the arguments to the subsequent calls.

Note: this is a racy function, if two (or more) calls are racing to call this function only the first's arguments will be used.

Type parameters#

Name Type
T T
R extends any[]

Parameters#

Name Type Description
this StaticThis<T, R> Implicit argument that is the child class type
...args R The constructor arguments for the child class

Returns#

T

An instance of the child class

Inherited from#

BaseStore.createInstance


getInstance#

Static getInstance<T, R>(this, strict?): T

Get the instance of the child class that was previously created.

Type parameters#

Name Type
T T
R extends any[]

Parameters#

Name Type Description
this StaticThis<T, R> Implicit argument that is the child class type
strict? true If false will return undefined instead of throwing when an instance doesn't exist. Default: true

Returns#

T

An instance of the child class

Inherited from#

BaseStore.getInstance

Static getInstance<T, R>(this, strict): undefined | T

Type parameters#

Name Type
T T
R extends any[]

Parameters#

Name Type
this StaticThis<T, R>
strict false

Returns#

undefined | T

Inherited from#

BaseStore.getInstance


resetInstance#

Static resetInstance(): void

Delete the instance of the child class.

Note: this doesn't prevent callers of getInstance from storing the result in a global.

There is no way in JS or TS to prevent globals like that.

Returns#

void

Inherited from#

BaseStore.resetInstance