Getting Started
Add Trigger to your project
npm i @datahook/trigger
Create a store as a regular .ts file
store.tsimport { CreateTable, CreateStore } from '@datahook/trigger';
type TaskOwner = {
ownerID: number;
firstName: string;
lastName: string;
}
type Task = {
ownerID: number;
description: string;
};
export const store = CreateStore({
taskOwners: CreateTable<TaskOwner>({ ownerID: [], firstName: [], lastName: [], }),
activeTasks: CreateTable<Task>({ ownerID: [], description: [], }),
completedTasks: CreateTable<Task>({ ownerID: [], description: [], }),
});
Use your store in your components
component.tsximport { store } from './store';
function MyComponent() {
const rows = store.activeTasks.use();
return (
<div>
There are {rows.length} active tasks in the table
</div>
)
}