Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
export class InceptionResult {
private readonly _serder: Serder
private readonly _sigs: string[]
private readonly promise: Promise<Response>
constructor(serder: Serder, sigs: string[], promise: Promise<Response>) {
this._serder = serder
this._sigs = sigs
this.promise = promise
}
get serder() {
return this._serder
}
get sigs() {
return this._sigs
}
async op(): Promise<any> {
let res = await this.promise
return await res.json()
}
}
Now callers that don't need anything other than the HTTP op can just call `await res.op()` and if you need the serder and sigs, they are available as getters.
Does this look "Ok"? If so, I'll be making similar changes to `rotate` and `interact`.
Number of replies: 0
Number of replies: 0
Number of replies: 0
Number of replies: 0
async function test1(): Promise<[string, string]> {
return ["hello", "world"];
}
Destructing it
let [a, b] = await test1();
I agree with rodolfo that you should await the Response "earlier", check status and handle any error, and only if things are positive return a promise with all results. Otherwise the caller will see partial results.
The create method could then look like this
async function create(): Promise<[Serder, string[], object]> {
...
return [serder, sigs, await res.json];
}
Number of replies: 0