INNER CODE UNIT · TypeScript
cleanup
dmotz/trystero · packages/nostr/src/index.ts:502
const cleanup = () => {
batchRemove(client, topic)
}
// Active rooms add the self topic before the root topic. Waiting only on
// the root keeps both topics in one batch while guaranteeing the REQ is
// written before createStrategy starts announcing.
return context.kind === 'root'
? waitForBatchFlush(client).then(() => cleanup)
: cleanup
},
publishTopic: (client, topic, msg, {kind}) => {
const payload = typeof msg === 'string' ? msg : toJson(msg)
if (kind === 'announce') {
announcementMessages.forRelay(client)[topic] = payload
}
return publishMessage(client, topic, payload, kind === 'announce')