add ability to run requests in background

This commit is contained in:
Leo Horie 2014-04-29 23:14:09 -04:00
parent f4a248f0a5
commit 91a32af76c
13 changed files with 123 additions and 41 deletions

View file

@ -290,6 +290,7 @@ where:
[String user,]
[String password,]
[Object<any> data,]
[Boolean background,]
[any unwrapSuccess(any data),]
[any unwrapError(any data),]
[String serialize(any dataToSerialize),]
@ -328,6 +329,19 @@ where:
Data to be sent. It's automatically placed in the appropriate section of the request with the appropriate serialization based on `method`
- **Boolean background** (optional)
Determines whether the `m.request` can affect template rendering. Defaults to false.
If this option is set to true, then the request does NOT call [`m.startComputation` / `m.endComputation`](mithril.computation.md), and therefore the completion of the request does not trigger an update of the view, even if data has been changed. This option is useful for running operations in the background (i.e. without user intervention).
In order to force a redraw after a background request, use [`m.redraw`](mithril.redraw.md)
```javascript
m.request({method: "GET", url: "/foo", background: true})
.then(m.redraw); //force redraw
```
- **any unwrapSuccess(any data)** (optional)
A preprocessor function to unwrap the data from a success response in case the response contains metadata wrapping the data.