Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Store

An interface between the extension storage and Dolos. It uses StoreElement or rather StoreElementProxy objects to provide an easy-to-work-with API.

Each Store instance manages its own cache, but there won't be a problem if you use multiple instances as the cache is kept up-to-date with the storage.

Hierarchy

  • Store

Index

Constructors

constructor

Properties

Private _cache

_cache: object

Type declaration

Private _getLock

_getLock: AsyncLock

Methods

buildIdentifier

  • buildIdentifier(serviceID: string, identifier: string, config?: Config): Promise<string>
  • Build an identifier which uniquely represents a medium for a service.

    oaram

    config - if not provided Store.getConfig is used.

    Parameters

    • serviceID: string
    • identifier: string
    • Optional config: Config

    Returns Promise<string>

get

  • Get the value for the provided key from the storage. This method returns a StoreElementProxy proxied object which can interact with the underlying value directly.

    If there's no value for the given key the provided default value is used. If no default value is provided it defaults to an empty object. The default value is not immediately saved to the storage. However if you edit an attribute of the StoreElementProxy object the saved value will include the default.

    Access to the storage is "locked" using the key. This means that if you start multiple get requests at the same time they will all finish at the same time and resolve to the same StoreElementProxy object. This is to provide consistency and ensure that the Store._cache cannot be overwritten, potentially creating a dead StoreElement that isn't updated.

    Type parameters

    • T

    Parameters

    • key: string
    • Optional defaultValue: T

    Returns Promise<StoreElementProxy<T>>

getAllStoreElements

  • getAllStoreElements(keys?: string[]): Promise<object>
  • Get a StoreElementProxy for every non-primitive element in the storage.

    Parameters

    • Optional keys: string[]

    Returns Promise<object>

getAnimeSubscriptions

getConfig

Private getRaw

  • getRaw(keys: string | string[] | null): Promise<object>
  • Parameters

    • keys: string | string[] | null

    Returns Promise<object>

getStoredAnimeInfo

getStoredAnimes

Private handleValueChanged

  • handleValueChanged(changes: object): Promise<void>
  • Parameters

    • changes: object
      • [key: string]: StorageChange

    Returns Promise<void>

set

  • set(key: string, value: any): Promise<void>
  • Store the given value under the given key in the storage.

    see

    StoreElementProxy objects returned by Store.get for a more convenient access.

    Parameters

    • key: string
    • value: any

    Returns Promise<void>

Private setRaw

  • setRaw(items: object): Promise<void>
  • Parameters

    • items: object

    Returns Promise<void>

Static buildLanguageIdentifier

  • buildLanguageIdentifier(config: Config): string
  • buildLanguageIdentifier(language: string, dubbed: boolean): string
  • Create an identifier for the language settings. The language identifier looks like this: <language>_<dub | sub>

    Parameters

    Returns string

  • Create an identifier for the language settings. The language identifier looks like this: <language>_<dub | sub>

    Parameters

    • language: string
    • dubbed: boolean

    Returns string

Generated using TypeDoc