RestfulPropertyKit Documentation Beta

Class Rest​Query​Result

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

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

received @escaping (() -> Void)

The closure to execute on failed completion.

sink(receive​Completion:​receive​Value:​)

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

receive​Completion @escaping ((Subscribers.​Completion<Rest​Query​Error>) -> Void)

The closure to execute on completion.

receive​Value @escaping ((Query​Type.​Query​Value) -> Void)

The closure to execute on receipt of a value.

sink(receive​Value:​)

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

receive​Value @escaping ((Query​Type.​Query​Value) -> Void)

The closure to execute on receipt of a value.