forked from Kieran/snort
11 lines
323 B
TypeScript
11 lines
323 B
TypeScript
import { useSyncExternalStore } from "react";
|
|
import { SystemSnapshot } from "@snort/system";
|
|
import { ExternalStore } from "@snort/shared";
|
|
|
|
export function useSystemState(system: ExternalStore<SystemSnapshot>) {
|
|
return useSyncExternalStore<SystemSnapshot>(
|
|
cb => system.hook(cb),
|
|
() => system.snapshot()
|
|
);
|
|
}
|