Skip to content

UserOptions

UserOptions — a class for managing personal options of the current user. Singleton instance is available after Frame initialization.

User options do not override application-wide option values.

ts
import { UserOptions } from '@aspro-cloud/miniapp-jssdk'

Methods

getInstance

Returns the current singleton instance of UserOptions. Call only after Frame initialization

ts
static getInstance(): UserOptions

destroy

Removes subscriptions and releases resources

ts
destroy(): void

get

Returns all options (OptionsValues) or a single option value (OptionValue) by identifier

ts
async get(): Promise<OptionsValues>
ts
async get(optionId: string): Promise<OptionValue>
ParameterTypeDescription
optionIdstringOption identifier

set

Saves multiple options at once or a single option value by identifier

ts
async set(values: OptionsValues): Promise<OptionsValues>
ParameterTypeDescription
valuesOptionsValuesObject with options to save multiple values
ts
async set(optionId: string, value: OptionValue): Promise<OptionValue>
ParameterTypeDescription
optionIdstringOption identifier
valueOptionValueOption value

Example

ts
import { App, UserOptions } from '@aspro-cloud/miniapp-jssdk'

await App.initializeFrame()

const userOptions = UserOptions.getInstance()

// get user option value
const theme = await userOptions.get('theme')

// save an option value
await userOptions.set('theme', 'dark')

// save multiple option values
await userOptions.set({
  theme: 'dark',
  compact: true
})
js
const App = window.ACloudMiniApp

const frame = await App.initializeFrame()

// get user option value
const theme = await frame.userOptions.get('theme');

// save an option value
await frame.userOptions.set('theme', 'dark');

// save multiple option values
await frame.userOptions.set({
  theme: 'dark',
  compact: true
});

Published under the MIT license.