Skip to content

Commit

Permalink
docs(core): 📝 add timeout setting description
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierfoucrier committed May 16, 2019
1 parent f082957 commit c969158
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions documentation/user/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ The namespace allow you to define **a unique name for each pages**. Barba mainly
| [`prefetchIgnore`](#prefetchignore) | Boolean \| string \| string[] | true | Prefetch strategy |
| [`prevent`](#prevent) | Function | (optional) | Custom prevent test |
| [`requestError`](#requesterror) | Function | (optional) | Custom request error callback |
| [`timeout`](#timeout) | Integer | 2000 | Custom request timeout (ms) |

#### `<transition>` object

Expand Down Expand Up @@ -515,6 +516,21 @@ barba.init({

> Note that if you use `barba.go()` directive without returning `false`, you will be redirected to the requested URL because Barba uses `barba.force()` to reach the page.
#### timeout
On slow network or with a high page weight, the server can take time to give a response to the user. In case the page take **more than timeout** to be loaded, it lead Barba to abort the transition and display a *Timeout error [2000]* message.

To prevent this behavior, you can increase the `timeout`:

```js
import barba from '@barba/core';

barba.init({
timeout: 5000
});
```

In addition, you can properly catch the error by using the [`requestError`](#requesterror) callback.

## Partial output

Barba sends a custom **HTTP Header** named `x-barba` in the `XMLHttpRequest`.
Expand Down
4 changes: 4 additions & 0 deletions documentation/user/prefetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ barba.use(barbaPrefetch);
// init Barba
barba.init();
```

> On slow network or with a high page weight, the server can take time to prefetch the response and can lead Barba to abort the transition and display a *Timeout error [2000]* message.
>
> See the [`timeout`](core.md#timeout) setting to properly manage this behavior.

0 comments on commit c969158

Please sign in to comment.