@rivi-software/radiotools-sdk-react 0.2.0 → 0.2.2
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/README.md +35 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @rivi-software/radiotools-sdk-react
|
|
2
|
+
|
|
3
|
+
React hooks for the RadioTools listener API, wrapping [`@rivi-software/radiotools-sdk`](../sdk-typescript). Generated from `@rivi-software/radiotools-contract`; do not edit `src/hooks.generated.ts` by hand.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @rivi-software/radiotools-sdk-react @rivi-software/radiotools-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires React 18 or newer.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { createStationClient } from "@rivi-software/radiotools-sdk";
|
|
17
|
+
import { useGetNowPlaying } from "@rivi-software/radiotools-sdk-react";
|
|
18
|
+
|
|
19
|
+
const client = createStationClient({ baseUrl, stationSlug, apiToken });
|
|
20
|
+
|
|
21
|
+
export function NowPlaying() {
|
|
22
|
+
const { data, error, loading, refresh } = useGetNowPlaying(client);
|
|
23
|
+
if (loading) return <p>Loading…</p>;
|
|
24
|
+
if (error) return <p>{error.message}</p>;
|
|
25
|
+
return <p>{data?.track?.title}</p>;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Create the client once, outside components or in a memo, so the hooks keep a stable reference.
|
|
30
|
+
|
|
31
|
+
## Hooks
|
|
32
|
+
|
|
33
|
+
`useGetStation`, `useGetCurrentBroadcast`, `useGetNowPlaying`, `useGetWeather`, `useGetTraffic`, `useRecommendedPollInterval`. Each returns `{ data, error, loading, refresh }`.
|
|
34
|
+
|
|
35
|
+
For anything else, call the client directly.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivi-software/radiotools-sdk-react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "React hooks for @rivi-software/radiotools-sdk (generated from @rivi-software/radiotools-contract)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"react": ">=18"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@types/react": "19.
|
|
25
|
-
"react": "19.
|
|
24
|
+
"@types/react": "19.3.0",
|
|
25
|
+
"react": "19.3.0",
|
|
26
26
|
"typescript": "5.9.3"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
|
-
"url": "https://github.com/
|
|
33
|
+
"url": "https://github.com/rivi-software/radiotools-sdk.git",
|
|
34
34
|
"directory": "packages/sdk-react"
|
|
35
35
|
}
|
|
36
36
|
}
|