brillout / react-streaming

React Streaming. Full-fledged & Easy.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about useAsync

tbrannam opened this issue · comments

I am building node and browser target modules in my project.

I was wondering if there were commonly used techniques that may allow me to strip the factory function from useAsync to essentially allow to be only ever run on the server, and to mask the existence of the upstream server (used in the fetch).

// node
const data = useAsync('key', () => fetch('http://foobar/resource').then(res => res.json());
// web
const data = useAsync('key', /* empty or empty function that never gets called */);

This is likely going to have to be bundler specific.

commented

I'd say it's out-of-scope for this project.

Feel free to fork it though, it isn't much code anyways.