HTTPRequest execution should return a Promise instead of a Publisher
Opened this issue · 0 comments
marcantoinefortier commented
Current interface
interface HttpRequest {
@JsName("execute")
fun execute(cancellableManager: CancellableManager): Publisher<HttpResponse>
} // ^^^^^^^^^
Desired interface
interface HttpRequest {
@JsName("execute")
fun execute(cancellableManager: CancellableManager): Promise<HttpResponse>
} // ^^^^^^^
Why?
A Promise
has a stronger contract than a Publisher
regarding the possible outcome of the HTTP request. The current interface is a bit "misleading" in the sense that a Publisher
can emit multiple values in time, while a Promise
would explicitly enforce that you will receive only one value/error.
Also, returning a Promise
would allow multiple HTTP requests to be chained more easily.