Package Exports
- @kalxjs/core
Readme
kalxjs Core
The core package of the kalxjs framework, providing the fundamental functionality for building modern web applications.
Features
- Reactive Data Binding: Automatically updates the DOM when data changes
- Component-Based Architecture: Create reusable and modular components
- Virtual DOM: Optimize rendering performance with efficient DOM updates
- Lifecycle Hooks: Control component behavior at different stages
Installation
npm install @kalxjs/coreBasic Usage
import kalxjs from '@kalxjs/core';
// Create a reactive object
const state = kalxjs.reactive({
count: 0
});
// Create a component
const Counter = kalxjs.defineComponent({
data() {
return {
message: 'Counter Example'
};
},
methods: {
increment() {
state.count++;
}
},
render(h) {
return h('div', { class: 'counter' }, [
h('h1', {}, this.message),
h('p', {}, `Count: ${state.count}`),
h('button', { onClick: this.increment }, 'Increment')
]);
}
});
// Create and mount the app
const app = kalxjs.createApp({
render(h) {
return h(Counter);
}
});
app.mount('#app');API Documentation
Reactivity
reactive(obj): Create a reactive objectref(value): Create a reactive referencecomputed(getter, setter?): Create a computed propertyeffect(fn): Run a function reactively
Component System
defineComponent(options): Define a componentcreateComponent(options): Create a component instance
Rendering
h(type, props, ...children): Create virtual DOM nodescreateElement(tag, props, children): Low-level element creation
Application
createApp(options): Create a new application instanceapp.mount(el): Mount the applicationapp.unmount(): Unmount the applicationapp.use(plugin, options?): Use a pluginapp.component(name, component): Register a global componentapp.provide(key, value): Provide a value to all components
License
MIT