-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathliveUpdateModule.ts
More file actions
38 lines (33 loc) · 966 Bytes
/
liveUpdateModule.ts
File metadata and controls
38 lines (33 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { NativeModules } from 'react-native';
import { IS_LIVE_UPDATE_ELIGIBLE_PLATFORM } from '../../../constants';
const { LiveUpdateModule } = NativeModules;
type LiveUpdateState = {
stationName: string;
nextStationName: string;
stationNumber: string;
nextStationNumber: string;
approaching: boolean;
stopped: boolean;
lineName: string;
lineColor: string;
passingStationName: string;
passingStationNumber: string;
progress: number;
boundStationName: string;
trainTypeName: string;
};
export const startLiveUpdate = (state?: LiveUpdateState) => {
if (IS_LIVE_UPDATE_ELIGIBLE_PLATFORM) {
LiveUpdateModule?.startLiveUpdate?.(state);
}
};
export const updateLiveUpdate = (state: LiveUpdateState) => {
if (IS_LIVE_UPDATE_ELIGIBLE_PLATFORM) {
LiveUpdateModule?.updateLiveUpdate?.(state);
}
};
export const stopLiveUpdate = () => {
if (IS_LIVE_UPDATE_ELIGIBLE_PLATFORM) {
LiveUpdateModule?.stopLiveUpdate?.();
}
};