Class
RestQueryResult
public final class RestQueryResult<QueryType> where QueryType: RestQuery
The result type of a REST query.
This result type contains a reference to the query as well as a future that will resolve to the new value or an error.
Properties
query
public let query: QueryType
The query associated with this result.
result
public let result: Future<QueryType.QueryValue, RestQueryError>
The query result as a future that will resolve to the new value or an error.
Methods
success(received:)
public func success(received: @escaping (() -> Void))
Attaches a subscriber with closure-based behavior.
Upon completion the success(received:) operator’s received closure indicates the successful termination of the query result.
Usage:
someQueryResult.success {
...
}
This method creates and returns a subscriber.
Parameters
| Name | Type | Description |
|---|---|---|
| received | @escaping (() -> Void) |
The closure to execute on successful completion. |
failure(received:)
public func failure(received: @escaping (() -> Void))
Attaches a subscriber with closure-based behavior.
Upon completion the failure(received:) operator’s received closure indicates the failure of the query.
Usage:
someQueryResult.failure {
...
}
This method creates and returns a subscriber.
Parameters
| Name | Type | Description |
|---|---|---|
| received | @escaping (() -> Void) |
The closure to execute on failed completion. |
sink(receiveCompletion:receiveValue:)
public func sink(receiveCompletion: @escaping ((Subscribers.Completion<RestQueryError>) -> Void), receiveValue: @escaping ((QueryType.QueryValue) -> Void))
Attaches a subscriber with closure-based behavior.
Use sink(receiveCompletion:receiveValue:) to observe values received by the future publisher and process them using a closure you specify.
Upon completion the sink(receiveCompletion:receiveValue:) operator’s receiveCompletion closure indicates the successful termination of the stream.
Usage:
someQueryResult.sink(receiveCompletion: { completion in
...
}, receiveValue: { value in
...
})
This method creates the subscriber and immediately requests an unlimited number of values, prior to returning the subscriber.
Parameters
| Name | Type | Description |
|---|---|---|
| receiveCompletion | @escaping ((Subscribers.Completion<RestQueryError>) -> Void) |
The closure to execute on completion. |
| receiveValue | @escaping ((QueryType.QueryValue) -> Void) |
The closure to execute on receipt of a value. |
sink(receiveValue:)
public func sink(receiveValue: @escaping ((QueryType.QueryValue) -> Void))
Attaches a subscriber with closure-based behavior.
Use sink(receiveValue:) to observe values received by the future publisher and process them using a closure you specify.
Usage:
someQueryResult.sink { value in
...
}
This method creates the subscriber and immediately requests an unlimited number of values, prior to returning the subscriber.
Parameters
| Name | Type | Description |
|---|---|---|
| receiveValue | @escaping ((QueryType.QueryValue) -> Void) |
The closure to execute on receipt of a value. |