feat: update devtools almost real time using signals

Signed-off-by: Heikki Hellgren <heikki.hellgren@op.fi>
This commit is contained in:
Heikki Hellgren
2023-12-05 15:35:36 +02:00
parent db84649e81
commit 59a4508efe
28 changed files with 114 additions and 84 deletions
+3 -3
View File
@@ -7,16 +7,16 @@ import { ApiRef } from '@backstage/core-plugin-api';
import { JsonObject } from '@backstage/types';
// @public (undocumented)
export type SignalsApi = {
export type SignalApi = {
subscribe(topic: string, onMessage: (message: JsonObject) => void): string;
unsubscribe(subscription: string): void;
};
// @public (undocumented)
export const signalsApiRef: ApiRef<SignalsApi>;
export const signalApiRef: ApiRef<SignalApi>;
// @public (undocumented)
export const useSignalsApi: (
export const useSignalApi: (
topic: string,
onMessage: (message: JsonObject) => void,
) => void;
@@ -17,12 +17,12 @@ import { createApiRef } from '@backstage/core-plugin-api';
import { JsonObject } from '@backstage/types';
/** @public */
export const signalsApiRef = createApiRef<SignalsApi>({
id: 'plugin.signals.service',
export const signalApiRef = createApiRef<SignalApi>({
id: 'plugin.signal.service',
});
/** @public */
export type SignalsApi = {
export type SignalApi = {
subscribe(topic: string, onMessage: (message: JsonObject) => void): string;
unsubscribe(subscription: string): void;
+1 -1
View File
@@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './SignalsApi';
export * from './SignalApi';
+1 -1
View File
@@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './useSignalsApi';
export * from './useSignalApi';
@@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { signalsApiRef } from '../api';
import { signalApiRef } from '../api';
import { useApi } from '@backstage/core-plugin-api';
import { JsonObject } from '@backstage/types';
import { useEffect, useState } from 'react';
/** @public */
export const useSignalsApi = (
export const useSignalApi = (
topic: string,
onMessage: (message: JsonObject) => void,
) => {
const signals = useApi(signalsApiRef);
const signals = useApi(signalApiRef);
const [subscription, setSubscription] = useState<null | string>(null);
useEffect(() => {
if (!subscription) {