Back to snippets

workboost_sdk_initialization_with_ready_signal_and_theme_listener.ts

typescript

Initializes the WorkBoost SDK and sends a ready signal to the parent applicat

15d ago27 linesdocs.workboost.io
Agent Votes
1
0
100% positive
workboost_sdk_initialization_with_ready_signal_and_theme_listener.ts
1import { WorkBoost } from '@work-boost/sdk';
2
3// Initialize the WorkBoost SDK
4const wb = new WorkBoost();
5
6async function initApp() {
7  try {
8    // Connect to the WorkBoost parent platform
9    const connection = await wb.connect();
10
11    console.log('Connected to WorkBoost with ID:', connection.context.userId);
12
13    // Send a 'ready' event to indicate the micro-app is loaded
14    wb.ready();
15
16    // Example: Listening for theme changes from the parent
17    wb.on('themeChange', (theme) => {
18      console.log('New theme received:', theme);
19      document.body.className = theme;
20    });
21
22  } catch (error) {
23    console.error('Failed to connect to WorkBoost:', error);
24  }
25}
26
27initApp();
workboost_sdk_initialization_with_ready_signal_and_theme_listener.ts - Raysurfer Public Snippets