subscription method

NdkResponse subscription({
  1. required List<Filter> filters,
  2. String name = '',
  3. String? id,
  4. RelaySet? relaySet,
  5. bool cacheRead = false,
  6. bool cacheWrite = false,
  7. Iterable<String>? explicitRelays,
  8. int? desiredCoverage,
})

Creates a low-level Nostr subscription

filters A list of filters to apply to the subscription
name An optional name for the subscription
id An optional ID for the subscription, overriding name
relaySet An optional set of relays to subscribe to
cacheRead Whether to read from cache
cacheWrite Whether to write results to cache
explicitRelays A list of specific relays to use, bypassing inbox/outbox
desiredCoverage The number of relays per pubkey to subscribe to, default: 2 \

Returns an NdkResponse containing the subscription results as stream

Implementation

NdkResponse subscription({
  required List<Filter> filters,
  String name = '',
  String? id,
  RelaySet? relaySet,
  bool cacheRead = false,
  bool cacheWrite = false,
  Iterable<String>? explicitRelays,
  int? desiredCoverage,
}) {
  return requestNostrEvent(NdkRequest.subscription(
    id ?? "$name-${Helpers.getRandomString(10)}",
    name: name,
    filters: filters.map((e) => e.clone()).toList(),
    relaySet: relaySet,
    cacheRead: cacheRead,
    cacheWrite: cacheWrite,
    explicitRelays: explicitRelays,
    desiredCoverage:
        desiredCoverage ?? RequestDefaults.DEFAULT_BEST_RELAYS_MIN_COUNT,
  ));
}