# wire.data.DataPromise

## Methods

Use the following methods on data promises.

| Name          | Description                                              |
| ------------- | -------------------------------------------------------- |
| resolve(data) | Resolves a promise as successful and returns the `data`. |
| reject        | Rejects a promise.                                       |

## Events

Use the following callbacks when working with data promises.

| Name       | Description                                           |
| ---------- | ----------------------------------------------------- |
| always     | Called when a promise is either resolved or rejected. |
| done       | Called when a promise is resolved.                    |
| fail       | Called when a promise is rejected.                    |
| processing | Called when a promise is pending an update.           |

```javascript
const promise = new wire.data.DataPromise();

promise
    .done( (data) => {
        // data is avaialble
    })
    .processing( () => {
        // new query is running
    })
    .fail( (ex) => {
        // processing failed
        // do something with the exception object
    })
    .always( () => {
        // all done whether fail or success
        // clean up    
    });
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wirebootstrap.com/wirebootstrap/reference/wire.data/wire.data.datapromise.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
