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.
const {
getSettings,
getNetworkSettings,
getDevices,
appReady,
sendNotification,
onSettingsChange,
onNetworkChange,
} = window as any;
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 => {}
const {
appReady
} = window as any;
appReady()
const changeWindowTitle = (newTitle: string): void => {}
const {
changeWindowTitle
} = window as any;
changeWindowTitle("You're a boomer")
interface UserSettings {
isDarkMode: boolean
isDoNotDisturb: boolean
username: string
profilePicture?: string
backgroundImage?: string
}
const getSettings = async (): Promise<UserSettings> => {}
const {
getSettings
} = window as any;
const settings: UserSettings = await getSettings()
interface ConnectionStatus {
isConnected: boolean
connectedTo: WifiNetwork | undefined
airplaneMode: boolean
connectedToVpn: boolean
}
const getNetworkSettings = async (): Promise<ConnectionStatus> => {}
const {
getNetworkSettings
} = window as any;
const network: ConnectionStatus = await getNetworkSettings()
interface LaptopDevice {
slot: number
metadata: {
deviceId: string
deviceLabel: string
[key: string]: any
}
}
const getDevices = async (): Promise<LaptopDevice[]> => {}
const {
getDevices
} = window as any;
const devices: LaptopDevice[] = await getDevices()
const sendNotification = (title: string, description: string): void => {}
const {
sendNotification
} = window as any;
sendNotification('Test title', 'Test description')
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 => {}
const {
getSettings
onSettingsChange
} = window as any;
let settings: UserSettings = await getSettings()
onSettingsChange((payload: UserSettings) => {
settings = payload
})
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 => {}
const {
getNetworkSettings
onNetworkChange
} = window as any;
let network: ConnectionStatus = await getNetworkSettings()
onNetworkChange((payload: ConnectionStatus) => {
network = payload
})