useEventLog

function
devtools-ui/src/hooks/useEventLog.ts:70
signature
useEventLog(storeId, options?): { clear: () => void; entries: EventLogEntry[] }

Maintains a chronological event log for a given store.

Parameters

NameTypeDescription
storeIdnull | stringThe store ID whose events to return, or null to get an empty slice (collection still runs for all stores).
NameTypeDescription
options?UseEventLogOptionsOptional configuration (see UseEventLogOptions).

Returns

{ clear: () => void; entries: EventLogEntry[] }, An object containing the entries array and a clear function.

Example

example
import { useEventLog } from "@yoltra/devtools-ui";

function EventTimeline({ storeId }: { storeId: string }) {
  const { entries, clear } = useEventLog(storeId, { maxEntries: 500 });
  return (
    <div>
      <button onClick={clear}>Clear</button>
      <ul>
        {entries.map((e, i) => (
          <li key={i}>{e.event.type} @ {e.timestamp}</li>
        ))}
      </ul>
    </div>
  );
}