onDowloadingPassioModelCallBacks

This method indicating downloading file status if model download from passio server.

Import the PassioSDK

import {
  PassioSDK,
  type Callback,
  type DownloadingError,
  type CompletedDownloadingFile
} from '@passiolife/nutritionai-react-native-sdk-v3'
  /**
   * This method indicating downloading file status if model download from passio server.
   * @param callback - A callback to receive for dowloading file lefts from queue.
   * @param callback - A callback to receive dowload file failed for some reason.
   * @returns A `Callback` that should be retained by the caller while dowloading is running. Call `remove` on the callback to terminate listeners and relase from memory.
   */
  onDowloadingPassioModelCallBacks: (
    downloadModelCallBack: DownloadModelCallBack
  ) => Callback

Example


const [leftFile, setDownloadingLeft] = useState<number | null>(null)
  
 useEffect(() => {
    const callBacks = PassioSDK.onDowloadingPassioModelCallBacks({
      completedDownloadingFile: ({ filesLeft }: CompletedDownloadingFile) => {
        setDownloadingLeft(filesLeft)
      },
      downloadingError: ({ message }: DownloadingError) => {
        console.log('DownloadingError ===>', message)
      },
    })
    return () => callBacks.remove()
  }, [])

Last updated