import { ReceiveGroupMessageType } from '../index.type'; export const useReceiveMessage = () => { const forEachGroupMessage = ( message: ReceiveGroupMessageType, deviceId: string, attributes: string[], Fn: (attribute: string, value: any, timespan: number) => void ) => { const { data = {} } = message; const bindMessage = data[deviceId]; for (const attribute of attributes) { const [latest] = bindMessage[attribute] || []; const [timespan, value] = latest || []; Fn?.(attribute, value, timespan); } }; return { forEachGroupMessage }; };