"rx-nostr"よりcreateRxNostrを、@rx-nostr/cryptoよりverifierをimportして以下のコードを書けば初期化できる
const rxNostr = createRxNostr({
eoseTimeout: 1000,
verifier,
});rxNostr.setDefaultRelaysに文字列の配列を渡すとリレー一覧を設定できる
"rx-nostr"よりcreateRxOneshotReqをimportして以下のコードを書けば単発でリクエストを送れる
import { createRxOneshotReq } from "rx-nostr";
// 単発で最新のテキストノートを5件だけ取得する例
const rxReq = createRxOneshotReq({
filters: {
kinds: [1],
limit: 5,
},
});
rxNostr.use(rxReq).subscribe(({ event }) => {
if (event.kind === 1) {
console.log(event.content);
}
});