Root element of the app
Data will be collected automatically
ReadonlydataData will be collected automatically
ReadonlylistenersReadonlyrootRoot element of the app
Create data collector
Basic usage
using dc = await app.collector('data.csv');
dc.add({ name: 'Alice', age: 25 });
dc.add({ name: 'Bob', age: 30 });
dc.final(); // get final text
dc.download(); // download data.csv
Add listeners
using dc = await app
.collector('data.csv')
.on('add', (row) => {
console.log('add a row', row);
})
.on('chunk', (chunk) => {
console.log('a chunk of raw is ready', chunk);
});
Create a scene
Create text scene
const Component = (props: { text: string }) => {
const el = document.createElement('div');
const ctx = getCurrentScene();
ctx.on('show', () => {
el.textContent = props.text; // update element
});
return {
node: el,
data: () => ({ text: el.textContent }),
};
};
using scene = app.scene(Component, {
adapter: createComponentAdapter((e) => e),
defaultProps: { text: 'default text' }, // default props is required
close_on: 'click',
duration: 100,
});
Disposable event emitter, use Set to manage listeners