sf-68d / app.js
simplex5's picture
Add 4 files
ac5ecb6 verified
raw
history blame contribute delete
769 Bytes
import SafeteansLLM from './safeteans-llm';
class App {
constructor({ el, data, methods, created }) {
// Create the LLM instance
this.llm = new SafeteansLLM();
// Mount the root component
this.render([{
el: el,
data: data,
methods: methods,
created: created,
}]);
}
render({ el, data, methods, created }) {
// Create the element
const element = createElement(el);
// Set the data and methods
Object.keys(data).forEach(key => element.dataset[key] = data[key]);
Object.keys(methods).forEach(key => element[key] = methods[key]);
// Set the created callback
if (created) created(element);
// Append the element to the body
document.body.appendChild(element);
}
}
export default App;