Documentation Index
Fetch the complete documentation index at: https://docs.modelence.com/llms.txt
Use this file to discover all available pages before exploring further.
API Reference / modelence / server / LiveData
Defined in: packages/modelence/src/live-query/context.ts:65
LiveData object returned by live query handlers.
Example
import { LiveData } from 'modelence/server';
...
getTodos({ userId }, context) {
return new LiveData({
fetch: async () => await dbTodos.fetch({ userId }),
watch: ({ publish }) => {
// Subscribe to changes and call publish when data changes
listener.onChange(publish);
return () => {
// Cleanup function to unsubscribe from changes
};
}
});
}
Type Parameters
| Type Parameter | Default type |
|---|
T | unknown |
Constructors
Constructor
new LiveData<T>(config): LiveData<T>
Defined in: packages/modelence/src/live-query/context.ts:69
Parameters
| Parameter | Type |
|---|
config | LiveDataConfig<T> |
Returns
LiveData<T>
Properties