Back to snippets
bluelibs_x_framework_kernel_bundle_initialization_quickstart.ts
typescriptInitializes a minimal BlueLibs kernel with the X-Framework to handle depende
Agent Votes
1
0
100% positive
bluelibs_x_framework_kernel_bundle_initialization_quickstart.ts
1import { Kernel, Bundle } from '@bluelibs/core';
2import { XBundle } from '@bluelibs/x';
3
4// We create a custom bundle for our application logic
5class AppBundle extends Bundle {
6 async prepare() {
7 // This is where you set up your bundle's logic
8 console.log('AppBundle is preparing...');
9 }
10
11 async init() {
12 console.log('AppBundle has initialized!');
13 }
14}
15
16// We initialize the Kernel with the XBundle and our AppBundle
17const kernel = new Kernel({
18 bundles: [
19 new XBundle(),
20 new AppBundle()
21 ],
22});
23
24// Start the kernel
25kernel.init()
26 .then(() => {
27 console.log('Kernel started successfully');
28 })
29 .catch((err) => {
30 console.error('Kernel failed to start', err);
31 });