Theme : Theme Information

更新时间:
2024-07-24
下载文档

Theme : Theme Information

Get the current display theme of EdgerOS, the App can dynamically select its own display style according to the theme information.

Functions

edger.theme()

  • Returns: {Promise} Promise object.

Get the current display theme of EdgerOS.

Example

edger.theme().then((data) => {
  const { theme } = data;
  console.log('Current theme:', theme);
}).catch(error => {
  console.error(error);
});

async / await

async function theme() {
  try {
    return await edger.theme();
  } catch (error) {
    console.error(error);
  }
}

The obtained data object contains the following member:

  • theme {String} Current theme style.

The theme possible values include: 'dark', 'light'. Developers can choose the appropriate App display style based on this setting.

Events

The unified event listener provided by Web-SDK:

const listener = (payload) => {
  // Event handling...
}

// add listener
edger.addEventListener('some-event', listener);

// or 
// onAction() is an alias of addEventListener().
edger.onAction('some-event', listener);

// remove listener
edger.removeEventListener('some-event', listener);

// remove all listeners
edger.removeAllListeners();

theme

This event will be generated when EdgerOS theme was changed.

Example

const listener = (payload) => {
  const { theme } = payload;
  console.log('Current theme:', theme);
}

edger.addEventListener('theme', listener);
文档内容是否对您有所帮助?
有帮助
没帮助