SnowCait on Nostr: Promise.withResolvers の使い方これでいいんだろうか async function ...
Promise.withResolvers の使い方これでいいんだろうか
async function send(relays: string[], event: Event): Promise<void> {
const { promise, resolve } = Promise.withResolvers<void>();
const rxNostr = createRxNostr({ verifier, okTimeout });
rxNostr.setDefaultRelays(relays);
rxNostr
.send(event, { completeOn: "all-ok", errorOnTimeout: false })
.subscribe({ complete: () => resolve });
return promise;
}
Published at
2024-09-04 02:50:32Event JSON
{
"id": "edc00b04caa9afbeb1bb7656a553cbdc1e350f41ad469374127723a17d9092e0",
"pubkey": "83d52b4363d2d1bc5a098de7be67c120bfb7c0cee8efefd8eb6e42372af24689",
"created_at": 1725418232,
"kind": 1,
"tags": [],
"content": "Promise.withResolvers の使い方これでいいんだろうか\n\nasync function send(relays: string[], event: Event): Promise\u003cvoid\u003e {\n const { promise, resolve } = Promise.withResolvers\u003cvoid\u003e();\n const rxNostr = createRxNostr({ verifier, okTimeout });\n rxNostr.setDefaultRelays(relays);\n rxNostr\n .send(event, { completeOn: \"all-ok\", errorOnTimeout: false })\n .subscribe({ complete: () =\u003e resolve });\n return promise;\n}",
"sig": "059c07e0e723253dcb1fac2fd4305ff1fc02e0ffd8962f6d8af530bc07e35e8beb67a80d89cd809dc6565e91fc5706972e327b6a7e311f8bb729e49320adbecd"
}