@ray-js/robot-data-stream
v0.0.5
Published
扫地机P2P数据流标准化组件
Downloads
383
Readme
English | 简体中文
@ray-js/robot-data-stream
Robot P2P data stream hooks
Installation
$ npm install @ray-js/robot-data-stream
# or
$ yarn add @ray-js/robot-data-stream
Develop
# watch compile component code
yarn watch
# watch compile demo
yarn start:tuya
Usage
import React from 'react';
import { View, Text } from '@ray-js/ray';
import { useP2PDataStream, StreamDataNotificationCenter } from '@ray-js/robot-data-stream';
import styles from './index.module.less';
const DemoBlock = ({ devId }) => {
const onReceiveMapData = (data: string) => {
StreamDataNotificationCenter.emit('receiveMapData', data);
};
const onReceivePathData = (data: string) => {
StreamDataNotificationCenter.emit('receivePathData', data);
};
const onReceiveAIPicData = (data: string) => {
StreamDataNotificationCenter.emit('receiveAIPicData', data);
};
const onReceiveAIPicHDData = (data: string) => {
StreamDataNotificationCenter.emit('receiveAIPicHDData', data);
};
const { appendDownloadStreamDuringTask } = useP2PDataStream(
devId,
onReceiveMapData,
onReceivePathData,
{
logTag: 'Robot_Stream',
onReceiveAIPicData,
onReceiveAIPicHDData
}
);
return (
<View className={styles.demoBlock}>
<View className={styles.demoBlockTitle}>
<Text className={styles.demoBlockTitleText}>{devId}</Text>
</View>
</View>
);
};
export default function Home() {
return (
<View className={styles.view}>
<DemoBlock devId="" />
</View>
);
}