chore: restore back to recipients + add test
Signed-off-by: Heikki Hellgren <heikki.hellgren@op.fi>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user