react-request-hook icon indicating copy to clipboard operation
react-request-hook copied to clipboard

[Feature Request] Async Request Factories

Open john-osullivan opened this issue 6 years ago • 0 comments

I'm working on an application right now and am running into a scenario where it'd be nice to have an asynchronous request factory. Specifically, before calling any of our requests, I'd like to check whether the auth token needs to be refreshed, and refresh it if so.

After looking through the source, I'm curious how much work it would take to get everything behaving again if the Request interface instead looked like:

import { XOR } from 'ts-xor';

export interface Request {
  (...args: any[]): XOR< Resource<any>, Promise<Resource<any>> >;
}

I'll fork and take a crack at it, make a PR if I can get anywhere with it. Just wanted to make this issue and get your take on whether you'd want this lib to support that functionality.

Thank you for the excellent library! 👍

john-osullivan avatar Aug 06 '19 21:08 john-osullivan