Getting Started

Add Trigger to your project

npm i @datahook/trigger

Create a store as a regular .ts file

store.ts
import { 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.tsx
import { store } from './store';

function MyComponent() {
    const rows = store.activeTasks.use();

    return (
        <div>
            There are {rows.length} active tasks in the table
        </div>
    )
}

Explore the full API for all available functionality

Explore the API
Built with in Halifax, Nova Scotia by JW