@tivio/sdk-react 3.1.4-alpha → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +9 -5
- package/README.md.bak +524 -0
- package/dist/device/tizen.d.ts +7 -0
- package/dist/index.js +1 -1
- package/dist/types/bundle.types.d.ts +31 -5
- package/dist/types/types.d.ts +11 -2
- package/package.json +4 -2
package/README.md
CHANGED
@@ -2,20 +2,24 @@
|
|
2
2
|
|
3
3
|
## Changelog
|
4
4
|
|
5
|
-
*
|
5
|
+
* v3.2.2
|
6
|
+
* minor: useRowsInScreen, useItemsInRow, useTaggedVideos - hasNextPage and loading added to pagination
|
7
|
+
* minor: useRowsInScreen, useItemsInRow, useTaggedVideos - implementation moved to remote bundle
|
8
|
+
* patch: Fixed Tivio startup on Tizen 6
|
9
|
+
* minor: Added `forceCloudFnResolver` option
|
10
|
+
* v3.2.1
|
11
|
+
* patch: fix of @tivio/common version
|
12
|
+
* v3.2.0
|
6
13
|
* minor: Added `capabilitiesOptions` for finer configuration of device capabilities
|
14
|
+
* minor: tag names are returned in correct language (the one from tivio config); language value should be one from enum "Language"
|
7
15
|
* v3.1.3
|
8
16
|
* patch: Hotfix made sure disabled Tivio does not break React Native
|
9
|
-
* internal: Fixed conf.bundleUrlOverride error handling
|
10
17
|
* v3.1.2
|
11
18
|
* patch: Allow `conf` prop of `TivioProvider` to be `null` or `undefined` in order to turn off Tivio
|
12
|
-
* internal: Added `runFeatureSupportCheck` to `TivioProvider`
|
13
19
|
* v3.1.1
|
14
20
|
* patch: fixed `setUser()` crash when bundle fails to load
|
15
21
|
* v3.1.0
|
16
|
-
* internal: refactored `useAd`, `useAdSegment`
|
17
22
|
* patch: `useAdSegment()` now returns null if no monetization is configured, ad segments are not managed in that situation
|
18
|
-
* internal: fixed refactored `setUser()`
|
19
23
|
* minor: enriched `AdSegment` type from `useAdSegment()`
|
20
24
|
* minor: Added `setUser()` function for login and logout
|
21
25
|
* v3.0.0
|
package/README.md.bak
ADDED
@@ -0,0 +1,524 @@
|
|
1
|
+
# @tivio/sdk-react
|
2
|
+
|
3
|
+
## Changelog
|
4
|
+
|
5
|
+
* v3.2.2
|
6
|
+
* minor: useRowsInScreen, useItemsInRow, useTaggedVideos - hasNextPage and loading added to pagination
|
7
|
+
* minor: useRowsInScreen, useItemsInRow, useTaggedVideos - implementation moved to remote bundle
|
8
|
+
* patch: Fixed Tivio startup on Tizen 6
|
9
|
+
* minor: Added `forceCloudFnResolver` option
|
10
|
+
* v3.2.1
|
11
|
+
* patch: fix of @tivio/common version
|
12
|
+
* v3.2.0
|
13
|
+
* minor: Added `capabilitiesOptions` for finer configuration of device capabilities
|
14
|
+
* minor: tag names are returned in correct language (the one from tivio config); language value should be one from enum "Language"
|
15
|
+
* v3.1.3
|
16
|
+
* patch: Hotfix made sure disabled Tivio does not break React Native
|
17
|
+
* internal: Fixed conf.bundleUrlOverride error handling
|
18
|
+
* v3.1.2
|
19
|
+
* patch: Allow `conf` prop of `TivioProvider` to be `null` or `undefined` in order to turn off Tivio
|
20
|
+
* internal: Added `runFeatureSupportCheck` to `TivioProvider`
|
21
|
+
* v3.1.1
|
22
|
+
* patch: fixed `setUser()` crash when bundle fails to load
|
23
|
+
* v3.1.0
|
24
|
+
* internal: refactored `useAd`, `useAdSegment`
|
25
|
+
* patch: `useAdSegment()` now returns null if no monetization is configured, ad segments are not managed in that situation
|
26
|
+
* internal: fixed refactored `setUser()`
|
27
|
+
* minor: enriched `AdSegment` type from `useAdSegment()`
|
28
|
+
* minor: Added `setUser()` function for login and logout
|
29
|
+
* v3.0.0
|
30
|
+
* minor: Added hook `useWatchWithoutAdsOffer` to trigger purchase dialog to "watch without ads", if available
|
31
|
+
* patch: fix peerDependency declaration for react, react-dom
|
32
|
+
* major: TivioProvider requires deviceCapabilities
|
33
|
+
* major: TivioProvider requires currency
|
34
|
+
* minor: add voucher support (see usePurchaseSubscription and useTransactionPayment hooks)
|
35
|
+
* minor: device limit support
|
36
|
+
* minor: drm (Widevine, PlayReady) support
|
37
|
+
* minor: watermarking support
|
38
|
+
* minor: add useSearch hook
|
39
|
+
* patch: price on video is 0 when purchased
|
40
|
+
* v2.4.2
|
41
|
+
* patch: added back changelog
|
42
|
+
* v2.4.1
|
43
|
+
* patch: improved doc about player wrapper
|
44
|
+
* v2.4.0
|
45
|
+
* patch: improved Player wrapper types
|
46
|
+
* minor: added Tivio DOM events `tivio_key_input_handling_change`, `tivio_context_switch` and `tivio_request_goto`
|
47
|
+
* patch: added support for remote code on browsers that do not implement [indexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API)
|
48
|
+
* patch: added support for browsers that do not implement [indexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API)
|
49
|
+
* v2.3.4
|
50
|
+
* patch: fix of usePurchaseSubscription not reactive
|
51
|
+
* v2.3.3
|
52
|
+
* patch: fix of useUser not updating
|
53
|
+
* v2.3.2
|
54
|
+
* patch: next app doesn't fail anymore due to "self is not defined"
|
55
|
+
* v2.3.1
|
56
|
+
* patch: fix of @tivio/common dependency
|
57
|
+
* v2.3.0
|
58
|
+
* minor: add useTaggedVideos that allows to fetch videos with given tags
|
59
|
+
* minor: add option to fetch tags (on hook useItemsInRow), useVideo always fetching videos tags
|
60
|
+
* v2.2.1
|
61
|
+
* patch: disable Sentry when no config is supplied to `TivioProvider`
|
62
|
+
* v2.2.0
|
63
|
+
* patch: reduced bundle size
|
64
|
+
* minor: disable Sentry when no config is supplied to `TivioProvider` or when Tivio is disabled `{ enable: false }`, or when Sentry is disabled via config `{ enableSentry: false }`
|
65
|
+
* v2.1.5
|
66
|
+
* patch fix of `useVideosInSection` hook (fetching video's monetizations)
|
67
|
+
* v2.1.4
|
68
|
+
* patch: fix re-rendering of `useAd` during non-skippable ads (requires core-react-dom@2.1.9)
|
69
|
+
* v2.1.3
|
70
|
+
* patch: fix changelog
|
71
|
+
* v2.1.2
|
72
|
+
* patch: Fixed exported types
|
73
|
+
* v2.1.1
|
74
|
+
* patch: TivioWidget now correctly reports `false` via `onEnabled` callback when in invalid internal state
|
75
|
+
* v2.1.0
|
76
|
+
* patch: fix of useItemsInRow hook
|
77
|
+
* patch: fix of useScreen hook
|
78
|
+
* add: useRowsInScreen hook
|
79
|
+
* v2.0.3
|
80
|
+
* patch: fix of useItemsInRow hook
|
81
|
+
* v2.0.2
|
82
|
+
* patch: screen and row IDs fixed
|
83
|
+
* `TivioBundle.subscriptions.subscribeToItemsInRow` now accepts user-defined ID via studio.tiv.io
|
84
|
+
* `TivioBundle.subscriptions.subscribeToScreen` now accepts user-defined ID via studio.tiv.io
|
85
|
+
* `Screen` and `Row` types returned by `useScreen()` return their user-defined IDs (`.id`) correctly
|
86
|
+
* v2.0.1
|
87
|
+
* no changes
|
88
|
+
* v2.0.0
|
89
|
+
* major: video.channelId can now be `string | null` used to be `string`
|
90
|
+
* minor: added data API and hooks for screens (screens, rows of screen and row items)
|
91
|
+
* hooks: `useScreen()`, `useItemsInRow()`
|
92
|
+
* api: `TivioBundle.subscriptions.subscribeToScreen`, `TivioBundle.subscriptions.subscribeToItemsInRow`
|
93
|
+
* v1.3.6
|
94
|
+
* ?
|
95
|
+
* v1.3.5
|
96
|
+
* minor: added WebPlayer props (canReplay, showMarkers, customShortcuts, enableKeyboardShortcuts, source.poster)
|
97
|
+
* v1.3.4
|
98
|
+
* ...
|
99
|
+
|
100
|
+
|
101
|
+
## Installation
|
102
|
+
|
103
|
+
Install @tivio/sdk-react along with its peer dependencies
|
104
|
+
```sh
|
105
|
+
npm i react@17 react-dom@17 @tivio/sdk-react
|
106
|
+
# or
|
107
|
+
yarn add react@17 react-dom@17 @tivio/sdk-react
|
108
|
+
```
|
109
|
+
|
110
|
+
## Initialization
|
111
|
+
|
112
|
+
Put Tivio Provider at the top level of your application:
|
113
|
+
|
114
|
+
``` javascript
|
115
|
+
import { TivioProvider } from '@tivio/sdk-react'
|
116
|
+
|
117
|
+
const config = {
|
118
|
+
secret: 'XXXXXXXXXX',
|
119
|
+
}
|
120
|
+
|
121
|
+
function App({children}) {
|
122
|
+
return (
|
123
|
+
<TivioProvider conf={config}>
|
124
|
+
{children}
|
125
|
+
</TivioProvider>
|
126
|
+
)
|
127
|
+
}
|
128
|
+
```
|
129
|
+
|
130
|
+
## Authentication
|
131
|
+
|
132
|
+
A logged-in user can access more features, such as making purchases. In order to authenticate a user with Tivio, use the `setUser()` method.
|
133
|
+
|
134
|
+
Verification of the user against 3rd party auth servers is implemented per customer.
|
135
|
+
|
136
|
+
```typescript
|
137
|
+
import { setUser } from '@tivio/sdk-react'
|
138
|
+
|
139
|
+
// Log in
|
140
|
+
|
141
|
+
// Payload is specific per customer
|
142
|
+
// A common use-case is sending an auth token inside the payload, which Tivio can use to verify the user
|
143
|
+
await setUser('userId', { token: 'xxx'})
|
144
|
+
|
145
|
+
// Log out
|
146
|
+
await setUser('userId', null)
|
147
|
+
```
|
148
|
+
|
149
|
+
## Tivio widget
|
150
|
+
|
151
|
+
Tivio widget is the main Tivio component which shows the widget and provides access to its channels, sections and videos.
|
152
|
+
Usage is very simple (be sure to set `id` to the widget ID you have configured in [Tivio Studio](https://studio.tiv.io/)):
|
153
|
+
|
154
|
+
``` javascript
|
155
|
+
import { TivioWidget } from '@tivio/sdk-react'
|
156
|
+
|
157
|
+
function Screen() {
|
158
|
+
return (
|
159
|
+
<TivioWidget id="theWidgetId" />
|
160
|
+
)
|
161
|
+
}
|
162
|
+
```
|
163
|
+
|
164
|
+
### Usage with smart TV navigation (focus control)
|
165
|
+
|
166
|
+
``` javascript
|
167
|
+
import { TivioWidget, TivioWidgetRef } from '@tivio/sdk-react'
|
168
|
+
|
169
|
+
function Screen() {
|
170
|
+
const ref = useRef<TivioWidgetRef>(null)
|
171
|
+
|
172
|
+
return (
|
173
|
+
<TivioWidget id="theWidgetId" ref={ref} onBlur={() => {/* widget lost focus */}}/>
|
174
|
+
<div>
|
175
|
+
<button onClick={() => ref.current?.focus({ x: 100 })}>Focus</button>
|
176
|
+
<button onClick={() => ref.current?.unfocus()}>Unfocus</button>
|
177
|
+
</div>
|
178
|
+
)
|
179
|
+
}
|
180
|
+
```
|
181
|
+
|
182
|
+
## Player wrapper
|
183
|
+
|
184
|
+
Player wrapper is the way how you can enhance your video player with Tivio features, such Tivio Ads. In order to start using Tivio player wrapper, wrap your player methods with PlayerWrapper, start using PlayerWrapper's methods instead of them to control your playback and start sending player events to Tivio PlayerWrapper.
|
185
|
+
|
186
|
+
### Wrap your player methods with Tivio player wrapper
|
187
|
+
|
188
|
+
``` javascript
|
189
|
+
import { useTivioReadyData } from '@tivio/sdk-react'
|
190
|
+
|
191
|
+
function CustomPlayer() {
|
192
|
+
const tivioData = useTivioReadyData()
|
193
|
+
|
194
|
+
useEffect(() => {
|
195
|
+
if (tivioData) {
|
196
|
+
// If your app uses multiple player instances, use different Tivio player wrapper for each
|
197
|
+
// distinguished by playerWrapperId
|
198
|
+
const playerWrapper = tivio.getPlayerWrapper({ playerWrapperId: 'PLAYER_1' })
|
199
|
+
|
200
|
+
// Pass your player methods to Tivio player wrapper
|
201
|
+
playerWrapper.register({
|
202
|
+
play: () => {
|
203
|
+
// Un-pause your player
|
204
|
+
},
|
205
|
+
pause: () => {
|
206
|
+
// Pause your player
|
207
|
+
},
|
208
|
+
seekTo: (ms: number) => {
|
209
|
+
// Seek to position in milliseconds using your player
|
210
|
+
},
|
211
|
+
setSource: (videoSource: InputSource) => {
|
212
|
+
// Send this video source to your player to load it
|
213
|
+
},
|
214
|
+
})
|
215
|
+
}
|
216
|
+
}, [tivioData])
|
217
|
+
}
|
218
|
+
```
|
219
|
+
|
220
|
+
### Start using Tivio player wrapper methods to control playback
|
221
|
+
|
222
|
+
``` javascript
|
223
|
+
// Channel source metadata, such as channel name, epg start and epg end are necessary
|
224
|
+
// for TV ad segment detection and application of ad strategies
|
225
|
+
const source = new ChannelSource(
|
226
|
+
'https://channel_prima_hd.m3u8',
|
227
|
+
{
|
228
|
+
// here put any additional metadata, for your use.
|
229
|
+
// This object will not be touched by Tivio
|
230
|
+
},
|
231
|
+
// channel name
|
232
|
+
// can also be prima hd, prima_hd, prima, Prima, PRIMA, etc.
|
233
|
+
// we will normalize it to snake case and add '_hd' if necessary
|
234
|
+
'Prima HD',
|
235
|
+
// program name
|
236
|
+
'Dr. House',
|
237
|
+
// description (optional)
|
238
|
+
'Episode about Dr. House being awesome',
|
239
|
+
// EPG start
|
240
|
+
new Date('2021-12-10T12:00:00'),
|
241
|
+
// EPG end
|
242
|
+
new Date('2021-12-10T13:40:00'),
|
243
|
+
)
|
244
|
+
|
245
|
+
// Send source to player
|
246
|
+
playerWrapper.onSourceChanged(source)
|
247
|
+
|
248
|
+
// Un-pause player
|
249
|
+
playerWrapper.play()
|
250
|
+
|
251
|
+
// Pause player
|
252
|
+
playerWrapper.pause()
|
253
|
+
}
|
254
|
+
```
|
255
|
+
|
256
|
+
### Start reporting player events to Tivio
|
257
|
+
|
258
|
+
``` javascript
|
259
|
+
// Report that source is playing
|
260
|
+
playerWrapper.onStateChanged('playing')
|
261
|
+
|
262
|
+
// Report that source is paused
|
263
|
+
playerWrapper.onStateChanged('paused')
|
264
|
+
|
265
|
+
// Report that source stopped playing
|
266
|
+
playerWrapper.onPlaybackEnded()
|
267
|
+
playerWrapper.onStateChanged('idle')
|
268
|
+
|
269
|
+
// Report video progress
|
270
|
+
playerWrapper.onTimeChanged(ms)
|
271
|
+
}
|
272
|
+
```
|
273
|
+
|
274
|
+
### Start reporting playback-related errors to Tivio
|
275
|
+
|
276
|
+
``` javascript
|
277
|
+
// Report that video failed to load (e.g. due to a wrong URI)
|
278
|
+
playerWrapper.onLoadError(new Error('video failed to load'))
|
279
|
+
|
280
|
+
// Report that video failed during playback (e.g. due to bad connection, corrupted chunks of stream video etc.)
|
281
|
+
// This type of error may be auto-recoverable
|
282
|
+
playerWrapper.onError(new Error('playback error'))
|
283
|
+
}
|
284
|
+
```
|
285
|
+
|
286
|
+
## Tivio DOM events
|
287
|
+
|
288
|
+
`TivioWidget` triggers these events on `window.document`.
|
289
|
+
|
290
|
+
1. To instruct the parent app to navigate to and focus a specific TivioWidget (e.g. after going back from a Tivio screen)
|
291
|
+
|
292
|
+
```typescript
|
293
|
+
document.addEventListener("tivio_request_goto", e => {
|
294
|
+
e.detail.widgetId; // string - Tivio widget ID to go navigate to in UI
|
295
|
+
});
|
296
|
+
```
|
297
|
+
2. To notify the parent app about context switch, i.e. where is the user located or what is he focusing
|
298
|
+
|
299
|
+
```typescript
|
300
|
+
document.addEventListener("tivio_context_switch", e => {
|
301
|
+
e.detail.context; // 'tivio' | 'parent' - where is the user located? - in Tivio or in parent app
|
302
|
+
|
303
|
+
// For context Tivio there are additional fields
|
304
|
+
e.detail.context; // 'tivio'
|
305
|
+
e.detail.contextLocation; // 'route' | 'overlay' | 'widget' - where in Tivio is the user located?
|
306
|
+
// - on a Tivio route, in parent app but looking at a full screen Tivio overlay,
|
307
|
+
// or in parent app and focus is on a Tivio widget
|
308
|
+
|
309
|
+
// For context Tivio contextLocation 'widget' there is an additional field of widget ID
|
310
|
+
e.detail.widgetId; // string - which Tivio widget is focused right now
|
311
|
+
});
|
312
|
+
```
|
313
|
+
3. To notify the parent app about whether it should be handling key input from RC (TV remote) or not. When inputHandler is 'tivio', the parent app should stop reacting to key input, when inputHandler is 'parent' the parent app should start reacting again.
|
314
|
+
|
315
|
+
```typescript
|
316
|
+
document.addEventListener("tivio_key_input_handling_change", e => {
|
317
|
+
e.detail.inputHandler; // 'tivio' | 'parent' - who should be handling RC input? - Tivio or parent app
|
318
|
+
});
|
319
|
+
```
|
320
|
+
|
321
|
+
## Data hooks
|
322
|
+
|
323
|
+
If you don't want to use TivioWidget, you can implement your own UI using React data hooks.
|
324
|
+
|
325
|
+
### useWidget hook
|
326
|
+
|
327
|
+
Gets Widget object and subscribes to its changes.
|
328
|
+
|
329
|
+
``` javascript
|
330
|
+
/**
|
331
|
+
* Use widget
|
332
|
+
* @param widgetId - widget id
|
333
|
+
*/
|
334
|
+
useWidget: (widgetId: string) => {
|
335
|
+
error: string | null;
|
336
|
+
data: Widget | null;
|
337
|
+
}
|
338
|
+
```
|
339
|
+
|
340
|
+
### useChannel hook
|
341
|
+
|
342
|
+
Gets Channel object and subscribes to its changes.
|
343
|
+
|
344
|
+
``` javascript
|
345
|
+
/**
|
346
|
+
* Use channel
|
347
|
+
* @param channelId - channel id
|
348
|
+
*/
|
349
|
+
useChannel: (channelId: string) => {
|
350
|
+
error: string | null;
|
351
|
+
data: Channel | null;
|
352
|
+
}
|
353
|
+
```
|
354
|
+
|
355
|
+
### useSection hook
|
356
|
+
|
357
|
+
Gets Section object and subscribes to its changes.
|
358
|
+
|
359
|
+
``` javascript
|
360
|
+
/**
|
361
|
+
* Use section
|
362
|
+
* @param sectionId - section id
|
363
|
+
*/
|
364
|
+
useSection: (sectionId: string) => {
|
365
|
+
error: string | null;
|
366
|
+
data: Section | null;
|
367
|
+
}
|
368
|
+
```
|
369
|
+
|
370
|
+
### useVideo hook
|
371
|
+
|
372
|
+
Gets Video object and subscribes to its changes.
|
373
|
+
|
374
|
+
``` javascript
|
375
|
+
/**
|
376
|
+
* Use video
|
377
|
+
* @param videoId - video id
|
378
|
+
*/
|
379
|
+
useVideo: (videoId: string) => {
|
380
|
+
error: string | null;
|
381
|
+
data: Video | null;
|
382
|
+
}
|
383
|
+
```
|
384
|
+
|
385
|
+
### useChannelsInWidget hook
|
386
|
+
|
387
|
+
Gets array of Channel objects and subscribes to their changes. It is possible to use `hasNextPage` and `fetchMore`
|
388
|
+
for pagination (returned in `data` object).
|
389
|
+
|
390
|
+
``` javascript
|
391
|
+
/**
|
392
|
+
* Use channels in widget
|
393
|
+
* @param widgetId - widget id
|
394
|
+
* @param [limit] - channels count, defaults to 10
|
395
|
+
*/
|
396
|
+
useChannelsInWidget: (widgetId: string, limit?: number) => {
|
397
|
+
error: string | null;
|
398
|
+
data: PaginationData<Channel> | null;
|
399
|
+
}
|
400
|
+
```
|
401
|
+
|
402
|
+
### useSectionsInChannel hook
|
403
|
+
|
404
|
+
Gets array of Section objects and subscribes to their changes. It is possible to use `hasNextPage` and `fetchMore`
|
405
|
+
for pagination (returned in `data` object).
|
406
|
+
|
407
|
+
``` javascript
|
408
|
+
/**
|
409
|
+
* Use section in channel
|
410
|
+
* @param channelId - channel id
|
411
|
+
* @param [limit] - sections count, defaults to 10
|
412
|
+
*/
|
413
|
+
useSectionsInChannel: (channelId: string, limit?: number) => {
|
414
|
+
error: string | null;
|
415
|
+
data: PaginationData<Section> | null;
|
416
|
+
}
|
417
|
+
```
|
418
|
+
|
419
|
+
### useVideosInSection hook
|
420
|
+
|
421
|
+
Gets array of Video objects and subscribes to their changes. It is possible to use `hasNextPage` and `fetchMore`
|
422
|
+
for pagination (returned in `data` object).
|
423
|
+
|
424
|
+
``` javascript
|
425
|
+
/**
|
426
|
+
* Use videos in section
|
427
|
+
* @param sectionId - section id
|
428
|
+
* @param [limit] - videos count, defaults to 10
|
429
|
+
*/
|
430
|
+
useVideosInSection: (sectionId: string, limit?: number) => {
|
431
|
+
error: string | null;
|
432
|
+
data: PaginationData<Video> | null;
|
433
|
+
}
|
434
|
+
```
|
435
|
+
|
436
|
+
### useScreen hook
|
437
|
+
Gets Screen object and subscribes to its changes.
|
438
|
+
|
439
|
+
```ts
|
440
|
+
/**
|
441
|
+
* Hook to fetch an app screen
|
442
|
+
* @param screenId - screen ID configured via studio.tiv.io
|
443
|
+
*/
|
444
|
+
useScreen: (screenId: string) => {
|
445
|
+
error: Error | null
|
446
|
+
data: Screen | null
|
447
|
+
}
|
448
|
+
|
449
|
+
// Example:
|
450
|
+
// Screens with their screenIds are configured via studio.tiv.io
|
451
|
+
const screenId = '890sdfvxoi'
|
452
|
+
const { error, data } = useScreen(screenId)
|
453
|
+
|
454
|
+
if (data) {
|
455
|
+
const screenName = data.name
|
456
|
+
const screenRows = data.rows
|
457
|
+
// ...
|
458
|
+
}
|
459
|
+
```
|
460
|
+
|
461
|
+
### useItemsInRow hook
|
462
|
+
|
463
|
+
Gets array of Video or Tag objects for a specified row. It is possible to use
|
464
|
+
`hasNextPage` and `fetchMore` for pagination (returned in `data` object).
|
465
|
+
|
466
|
+
*(Note: Does not subscribe to changes in video objects, in order to refresh data it is necessary to reload the app.)*
|
467
|
+
|
468
|
+
```ts
|
469
|
+
/**
|
470
|
+
* Hook to fetch row items for rows received from `useScreen()`
|
471
|
+
* @param id - row ID configured via studio.tiv.io
|
472
|
+
* @param options.limit - items limit
|
473
|
+
* @param options.noLimit - disable/enable pagination (will fetch all items)
|
474
|
+
* @param options.fecthTags - disable/enable tags fetching
|
475
|
+
*/
|
476
|
+
useItemsInRow: (id: string, options: {limit?: number, noLimit?: boolean, fecthTags?: boolean}) => {
|
477
|
+
error: Error | null
|
478
|
+
data: PaginationData<Video | Tag> | null
|
479
|
+
isLoading: boolean
|
480
|
+
}
|
481
|
+
|
482
|
+
// Example:
|
483
|
+
// Rows and their row ID can be loaded using useScreen() hook
|
484
|
+
const Row = ({ id }: { id: string}) => {
|
485
|
+
const rowData = useItemsInRow(id, 10)
|
486
|
+
|
487
|
+
return <div>
|
488
|
+
<div>Row id: {id}</div>
|
489
|
+
Count: ({rowData.data?.items.length})
|
490
|
+
<div>
|
491
|
+
{rowData.isLoading && <div>Loading...</div>}
|
492
|
+
{rowData.data?.items.map(item => (
|
493
|
+
<div>
|
494
|
+
<div>{item.name}</div>
|
495
|
+
<img src={item.cover} alt={item.name} />
|
496
|
+
</div>
|
497
|
+
))}
|
498
|
+
</div>
|
499
|
+
<button onClick={() => rowData.data?.fetchMore()}>more</button>
|
500
|
+
</div>
|
501
|
+
}
|
502
|
+
```
|
503
|
+
|
504
|
+
### useTaggedItems hook
|
505
|
+
|
506
|
+
Allows to fetch videos with given tags.
|
507
|
+
|
508
|
+
```ts
|
509
|
+
/**
|
510
|
+
* Hook to fetch row items for rows received from `useScreen()`
|
511
|
+
* @param id - row ID configured via studio.tiv.io
|
512
|
+
* @param options.limit - items limit
|
513
|
+
* @param options.noLimit - disable/enable pagination (will fetch all items)
|
514
|
+
* @param options.fecthTags - disable/enable tags fetching
|
515
|
+
*/
|
516
|
+
useTaggedItems: (tagIds: string[], {limit?: number, noLimit?: boolean, fecthTags?: boolean}) => {
|
517
|
+
error: Error | null
|
518
|
+
data: PaginationData<Video> | null
|
519
|
+
}
|
520
|
+
|
521
|
+
|
522
|
+
# Deprecations
|
523
|
+
- Video.url will be removed in version 3.0.0, use Video.uri attribute instead
|
524
|
+
- Video.cover will be removed in version 3.0.0, use Video.assets attribute instead
|