@equinor/fusion-framework-react-module-signalr 4.0.0 → 4.0.1
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 +6 -0
- package/README.md +57 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +11 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +5 -5
- package/src/index.ts +11 -0
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @equinor/fusion-framework-react-module-signalr
|
|
2
|
+
|
|
3
|
+
React hooks for the Fusion SignalR module. Subscribe to real-time SignalR hub topics from React components with automatic connection management.
|
|
4
|
+
|
|
5
|
+
**Import:**
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { useTopic, enableSignalR } from '@equinor/fusion-framework-react-module-signalr';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Exports
|
|
12
|
+
|
|
13
|
+
| Export | Type | Description |
|
|
14
|
+
| --------------------- | -------- | --------------------------------------------------------- |
|
|
15
|
+
| `useTopic` | Hook | Subscribe to a SignalR topic using the closest module scope |
|
|
16
|
+
| `useProviderTopic` | Hook | Subscribe to a SignalR topic with an explicit provider |
|
|
17
|
+
| `enableSignalR` | Function | Enable the SignalR module in a configurator |
|
|
18
|
+
| `Topic` | Class | A SignalR topic instance for pub/sub messaging |
|
|
19
|
+
| `ISignalRConfigurator`| Type | Configurator interface |
|
|
20
|
+
| `SignalRHubConfig` | Type | Hub connection configuration |
|
|
21
|
+
| `SignalRModule` | Type | Module type definition |
|
|
22
|
+
|
|
23
|
+
## useTopic
|
|
24
|
+
|
|
25
|
+
Subscribe to a SignalR hub topic. Returns a `Topic<T>` instance that exposes an observable message stream.
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { useTopic } from '@equinor/fusion-framework-react-module-signalr';
|
|
29
|
+
|
|
30
|
+
type NotificationPayload = { message: string; severity: 'info' | 'warning' };
|
|
31
|
+
|
|
32
|
+
const Notifications = () => {
|
|
33
|
+
const topic = useTopic<NotificationPayload>('notifications-hub', 'alerts');
|
|
34
|
+
|
|
35
|
+
// topic.message$ is an Observable<NotificationPayload>
|
|
36
|
+
// topic.send(payload) publishes to the hub
|
|
37
|
+
|
|
38
|
+
return <div>Listening for alerts…</div>;
|
|
39
|
+
};
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## useProviderTopic
|
|
43
|
+
|
|
44
|
+
Same as `useTopic`, but accepts an explicit `ISignalRProvider` instead of resolving from the module scope. Use this in libraries or when multiple providers are available.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { useProviderTopic } from '@equinor/fusion-framework-react-module-signalr';
|
|
48
|
+
import type { ISignalRProvider } from '@equinor/fusion-framework-module-signalr';
|
|
49
|
+
|
|
50
|
+
declare const provider: ISignalRProvider;
|
|
51
|
+
|
|
52
|
+
const topic = useProviderTopic<MyPayload>(provider, 'hub-id', 'topic-id');
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Related
|
|
56
|
+
|
|
57
|
+
- [`@equinor/fusion-framework-module-signalr`](../../../modules/signalr/README.md) — the underlying SignalR module
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React integration for the Fusion SignalR module.
|
|
3
|
+
*
|
|
4
|
+
* Provides hooks for subscribing to SignalR hub topics from React components.
|
|
5
|
+
* Use {@link useTopic} for module-scoped access or {@link useProviderTopic}
|
|
6
|
+
* when injecting a provider explicitly.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link enableSignalR} to enable the module in a configurator.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
1
12
|
export { useSignalRProvider as useProviderTopic } from './use-signalr-provider';
|
|
2
13
|
export { useTopic } from './use-signalr';
|
|
3
14
|
export { Topic, enableSignalR } from '@equinor/fusion-framework-module-signalr';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,kBAAkB,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC"}
|
package/dist/esm/version.js
CHANGED