besarthoxhaj / phoenix

React native project example
9 stars 1 forks source link

Dealing with timeouts for fetch #33

Open nikhilaravi opened 8 years ago

nikhilaravi commented 8 years ago

May want to reject the fetch promise automatically after a certain time elapsed.

Possible solution from https://github.com/whatwg/fetch/issues/179

const oldfetch = fetch;
fetch = function(input, opts) {
    return new Promise((resolve, reject) => {
        setTimeout(reject, opts.deadline);
        oldfetch(input, opts).then(resolve, reject);
    });
}

Not sure if this will be a problem for us - @besarthoxhaj what do you think?

besarthoxhaj commented 8 years ago

Like it! Should we implement it in https://github.com/besarthoxhaj/phoenix/issues/14?

nikhilaravi commented 8 years ago

@besarthoxhaj do you think it is necessary? Can you think of any situations in which we might have a problem with the request taking too long and having to abort it?

besarthoxhaj commented 8 years ago

@nikhilaravi it happened sometimes when requesting a new deck. We always solved the problem by refreshing the app, now we can implement this solution.