EML Docs

Background

Background fetches the background image currently set in EML AdminTool. Apply it to the launcher window on startup. Always implement a fallback for when no background is configured.

Warning

Background requires an EML AdminTool instance. It is not available in agnostic mode.

import { Background } from 'eml-lib'

getBackground()

async function getBackground() {
  const background = new Background('https://at.myserver.com')

  try {
    const bg = await background.getBackground()

    if (bg !== null) {
      document.body.style.backgroundImage = `url('${bg.url}')`
    }
    // else: keep your launcher's default background
  } catch (err) {
    console.error(err)
  }
}

Constructor

ParameterTypeDescriptionRequired?
urlstringThe URL of your EML AdminTool instance.Yes

getBackground() method

Fetches the currently active background from EML AdminTool.

Returns: Promise<IBackground> — The background data if a background is set. • Promise<null> — If no background has been set (use your launcher’s default).

Throws: FETCH_ERROR — If the request to EML AdminTool fails.