Home Reference Source
import Settings from '@osjs/client/src/settings.js'
public class | source

Settings

OS.js Settings Manager

Constructor Summary

Public Constructor
public

constructor(core: Core, options: SettingsOptions)

Create application

Member Summary

Public Members
public

The settings adapter

public

Core instance reference

public

Internal timeout reference used for debouncing

public

settings: {name: *}

The settings tree

Method Summary

Public Methods
public

Clears a namespace by root key

public

get(ns: string, key: string, defaultValue: *): *

Gets a settings entry by key (cached)

public

init(): *

Initializes settings adapter

public

Loads settings

public

Saves settings

public

set(ns: string, key: string, value: *): Settings

Sets a settings entry by root key (but does not save).

Public Constructors

public constructor(core: Core, options: SettingsOptions) source

Create application

Params:

NameTypeAttributeDescription
core Core

Core reference

options SettingsOptions

Options

Public Members

public adapter: SettingsAdapter source

The settings adapter

public core: Core source

Core instance reference

public debounce: object source

Internal timeout reference used for debouncing

public settings: {name: *} source

The settings tree

Public Methods

public clear(ns: string): Promise<boolean> source

Clears a namespace by root key

Params:

NameTypeAttributeDescription
ns string

The namespace

Return:

Promise<boolean>

public get(ns: string, key: string, defaultValue: *): * source

Gets a settings entry by key (cached)

Params:

NameTypeAttributeDescription
ns string
  • optional

The namespace

key string
  • optional

The key to get the value from

defaultValue *
  • optional

If result is undefined, return this instead

Return:

*

public init(): * source

Initializes settings adapter

Return:

*

public load(): Promise<boolean> source

Loads settings

Return:

Promise<boolean>

public save(): Promise<boolean> source

Saves settings

Return:

Promise<boolean>

public set(ns: string, key: string, value: *): Settings source

Sets a settings entry by root key (but does not save).

Params:

NameTypeAttributeDescription
ns string

The namespace

key string
  • optional

The key to set

value *
  • optional

The value to set

Return:

Settings

This