Skip to content

Latest commit

 

History

History
26 lines (16 loc) · 765 Bytes

File metadata and controls

26 lines (16 loc) · 765 Bytes

Worklets

nitroFetchOnWorklet() lets you run parsing/mapping off the JS thread using react-native-worklets.

Usage

import { nitroFetchOnWorklet } from 'react-native-nitro-fetch';

const map = (payload: { bodyString?: string }) => {
  'worklet';
  return JSON.parse(payload.bodyString ?? '{}');
};

const data = await nitroFetchOnWorklet('https://httpbin.org/get', undefined, map, { preferBytes: false });

Options

  • preferBytes (default false): when true, sends bodyBytes to the mapper; when false, sends bodyString.
  • runtimeName: optional name for the created worklet runtime.

Notes

  • Ensure react-native-worklets is installed in your app to get off-thread execution.