@checkstack/signal-frontend 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/package.json +1 -1
- package/src/useSignal.ts +14 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @checkstack/signal-frontend
|
|
2
2
|
|
|
3
|
+
## 0.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @checkstack/signal-common@0.0.3
|
|
8
|
+
|
|
9
|
+
## 0.0.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- cb82e4d: Improved `counter` and `pie` auto-chart types to show frequency distributions instead of just the latest value. Both chart types now count occurrences of each unique value across all runs/buckets, making them more intuitive for visualizing data like HTTP status codes.
|
|
14
|
+
|
|
15
|
+
Changed HTTP health check chart annotations: `statusCode` now uses `pie` chart (distribution view), `contentType` now uses `counter` chart (frequency count).
|
|
16
|
+
|
|
17
|
+
Fixed scrollbar hopping when health check signals update the accordion content. All charts now update silently without layout shift or loading state flicker.
|
|
18
|
+
|
|
19
|
+
Refactored health check visualization architecture:
|
|
20
|
+
|
|
21
|
+
- `HealthCheckStatusTimeline` and `HealthCheckLatencyChart` now accept `HealthCheckDiagramSlotContext` directly, handling data transformation internally
|
|
22
|
+
- `HealthCheckDiagram` refactored to accept context from parent, ensuring all visualizations share the same data source and update together on signals
|
|
23
|
+
- `HealthCheckSystemOverview` simplified to use `useHealthCheckData` hook for consolidated data fetching with automatic signal-driven refresh
|
|
24
|
+
|
|
25
|
+
Added `silentRefetch()` method to `usePagination` hook for background data refreshes without showing loading indicators.
|
|
26
|
+
|
|
27
|
+
Fixed `useSignal` hook to use a ref pattern internally, preventing stale closure issues. Callbacks now always access the latest values without requiring manual memoization or refs in consumer components.
|
|
28
|
+
|
|
29
|
+
Added signal handling to `useHealthCheckData` hook for automatic chart refresh when health check runs complete.
|
|
30
|
+
|
|
3
31
|
## 0.0.2
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/package.json
CHANGED
package/src/useSignal.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect,
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
2
|
import type { Signal } from "@checkstack/signal-common";
|
|
3
3
|
import { useSignalContext } from "./SignalProvider";
|
|
4
4
|
|
|
@@ -8,6 +8,9 @@ import { useSignalContext } from "./SignalProvider";
|
|
|
8
8
|
* The callback will be invoked whenever the signal is received.
|
|
9
9
|
* Subscriptions are automatically cleaned up on unmount.
|
|
10
10
|
*
|
|
11
|
+
* Note: The callback is stored in a ref internally, so you don't need to
|
|
12
|
+
* memoize it or worry about stale closures - the latest callback is always used.
|
|
13
|
+
*
|
|
11
14
|
* @example
|
|
12
15
|
* ```tsx
|
|
13
16
|
* import { NOTIFICATION_RECEIVED } from "@checkstack/notification-common";
|
|
@@ -27,12 +30,19 @@ export function useSignal<T>(
|
|
|
27
30
|
): void {
|
|
28
31
|
const { subscribe } = useSignalContext();
|
|
29
32
|
|
|
30
|
-
//
|
|
31
|
-
|
|
33
|
+
// Store callback in ref to always use the latest version
|
|
34
|
+
// This prevents stale closure issues without requiring consumers to memoize
|
|
35
|
+
const callbackRef = useRef(callback);
|
|
36
|
+
callbackRef.current = callback;
|
|
32
37
|
|
|
33
38
|
useEffect(() => {
|
|
39
|
+
// Create a stable wrapper that always calls the latest callback
|
|
40
|
+
const stableCallback = (payload: T) => {
|
|
41
|
+
callbackRef.current(payload);
|
|
42
|
+
};
|
|
43
|
+
|
|
34
44
|
return subscribe(signal, stableCallback);
|
|
35
|
-
}, [signal,
|
|
45
|
+
}, [signal, subscribe]);
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
/**
|