xhrSender
Packageβ
Installationβ
- npm
- Yarn
- pnpm
npm install @rpldy/sender
yarn add @rpldy/sender
pnpm add @rpldy/sender
Detailsβ
type send = SendMethod
- See: SendMethod
This is the default send method used by Uploady/Uploader.
Normally, it is used internally and there is no reason to interact with this method directly.
However, Enhancers may want to wrap the send functionality with some custom logic.
Exampleβ
import { Uploady } from "@rpldy/uploady";
import { send } from "@rpldly/sender";
const mySend = (items, url, sendOptions, onProgress) => {
//implement some custom logic here
return send(items, url, sendOptions, onProgress);
};
const MyApp = () => {
return <Uploady send={mySend}>
<RestOfMyApp/>
</Uploady>;
};
Alternatively, you can also create a reusable enhancer that will set your custom send method:
const myEnhancer = (uploader) => {
//make uploader use the custom send method
uploader.update({ send: mySend });
return uploader;
};
const MyApp = () => {
return <Uploady enhancer={myEnhancer}>
<RestOfMyApp/>
</Uploady>;
};