chore: restore back to recipients + add test

Signed-off-by: Heikki Hellgren <heikki.hellgren@op.fi>
This commit is contained in:
Heikki Hellgren
2024-02-01 20:28:04 +02:00
parent dde856b228
commit 7ce5f0009a
9 changed files with 55 additions and 18 deletions
+1
View File
@@ -27,6 +27,7 @@ export interface SignalSubscriber {
// @public (undocumented)
export const useSignal: (channel: string) => {
lastSignal: JsonObject | null;
isSignalsAvailable: boolean;
};
// (No @packageDocumentation comment for this package)
+5 -2
View File
@@ -16,7 +16,7 @@
import { signalApiRef } from '../api';
import { useApiHolder } from '@backstage/core-plugin-api';
import { JsonObject } from '@backstage/types';
import { useEffect, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';
/** @public */
export const useSignal = (channel: string) => {
@@ -40,5 +40,8 @@ export const useSignal = (channel: string) => {
};
}, [signals, channel]);
return { lastSignal };
// Can be used to fallback (for example to long polling) if signals are not available in the system
const isSignalsAvailable = useMemo(() => !signals, [signals]);
return { lastSignal, isSignalsAvailable };
};