@ray-js/robot-data-stream
v0.0.2
Published
扫地机P2P数据流标准化组件
Downloads
252
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, { useEffect } 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)
}
useEffect(() => {
useP2PDataStream(devId, onReceiveMapData, onReceivePathData);
}, []);
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>
);
}