Files
pezkuwi-ui/packages/ui-settings
Nikos Kontakis 851c452782 add new type in api - settings in order to support different types of… (#476)
* add new type in api - settings in order to support different types of 'urls' - json-rpc and substrate-connect; This makes the previous used apiURL deprecated

* Alter name from apiTypeUrl to apiType

* export types of possible endpoints

* minor fix on sequence of vars

* Fix lint error concerning imports

* Fix lint error concerning imports

* Fix PR comments: import types instead of import; seperate types from settings

* fix lint error

* Update packages/ui-settings/src/types.ts

Co-authored-by: Jaco <jacogr@gmail.com>

Co-authored-by: Jaco <jacogr@gmail.com>
2021-06-15 12:25:57 +02:00
..
2018-12-05 11:35:28 +01:00
2021-06-14 07:17:52 +00:00
2019-02-27 11:18:35 +01:00

@polkadot/ui-settings

Manages app settings including endpoints, themes and prefixes

Usage Examples

User preferences are set as a settings object in the browser's local storage.

import settings from '@polkadot/ui-settings';

render () {
  // get api endpoint for the selected chain
  const WS_URL = settings.apiUrl();

  // get the selected il8n language
  const language = settings.il8nLang();

  // get all available il8n languages
  const languages = settings.availableLanguages();

  // update settings
  const updatedSettings = {
    ...settings,
    i18nLang: 'Arabic'
  }
  settings.set(updatedSettings);

  // NOTE: API currently does not handle hot reconnecting properly,
  so you need to manually reload the page after updating settings.
  window.location.reload();
}

Used by

Apps that currently use the settings package