Imported methods

window / globalThis object

Once app is opened, we import and bind some usefull js methods to windows / globalThis object. While using these, you can get settings from laptop, change window title, track settings, network changes and so on. Please read references below.

Import example

example.ts
 const {
   getSettings,
   getNetworkSettings,
   getDevices,
   appReady,
   sendNotification,
   onSettingsChange,
   onNetworkChange,
 } = window as any;

appReady()

You are required to trigger appReady() method, once your app is loaded. This disables loading indicator in opened app window. If you set ignoreInternalLoading to true while registering custom app, loading indicator won't show up, and you won't need to trigger this method.

 const appReady = (): void => {}

Usage example

  const {
      appReady
  } = window as any;

  appReady()

changeWindowTitle(title)

const changeWindowTitle = (newTitle: string): void => {}

Usage example

  const {
      changeWindowTitle
  } = window as any;

  changeWindowTitle("You're a boomer")

getSettings()

interface UserSettings {
     isDarkMode: boolean
     isDoNotDisturb: boolean
     username: string
     profilePicture?: string
     backgroundImage?: string
 }

const getSettings = async (): Promise<UserSettings> => {}

Usage example



  const {
      getSettings
  } = window as any;

  const settings: UserSettings = await getSettings()

getNetworkSettings()

interface ConnectionStatus {
     isConnected: boolean
     connectedTo: WifiNetwork | undefined
     airplaneMode: boolean
     connectedToVpn: boolean
 }

const getNetworkSettings = async (): Promise<ConnectionStatus> => {}

Usage example



  const {
      getNetworkSettings
  } = window as any;

  const network: ConnectionStatus = await getNetworkSettings()

getDevices()

interface LaptopDevice {
     slot: number
     metadata: {
         deviceId: string
         deviceLabel: string
         [key: string]: any
     }
 }

 const getDevices = async (): Promise<LaptopDevice[]> => {}

Usage example

  const {
      getDevices
  } = window as any;

  const devices: LaptopDevice[] = await getDevices()

sendNotification(title, description)

 const sendNotification = (title: string, description: string): void => {}

Usage example

  const {
      sendNotification
  } = window as any;

  sendNotification('Test title', 'Test description')

onSettingsChange(cb)

You can listen you user settings change and act on those changes.

interface UserSettings {
     isDarkMode: boolean
     isDoNotDisturb: boolean
     username: string
     profilePicture?: string
     backgroundImage?: string
 }

const onSettingsChange = (callback: (data: UserSettings): void): void => {}

Usage example



  const {
      getSettings
      onSettingsChange
  } = window as any;

  let settings: UserSettings = await getSettings()

  onSettingsChange((payload: UserSettings) => {
      settings = payload
  })

onNetworkChange(cb)

You can listen you user settings change and act on those changes.

interface ConnectionStatus {
     isConnected: boolean
     connectedTo: WifiNetwork | undefined
     airplaneMode: boolean
     connectedToVpn: boolean
 }

const onNetworkChange = (callback: (data: ConnectionStatus): void): void => {}

Usage example



  const {
      getNetworkSettings
      onNetworkChange
  } = window as any;

  let network: ConnectionStatus = await getNetworkSettings()

  onNetworkChange((payload: ConnectionStatus) => {
      network = payload
  })