Skip to main content

Web3SubscriptionManager <API, RegisteredSubs>

Index

Constructors

publicconstructor

  • @example
    const requestManager = new Web3RequestManager("ws://localhost:8545");
    const subscriptionManager = new Web3SubscriptionManager(requestManager, {});

    Type parameters

    • API: unknown = unknown
    • RegisteredSubs: {} = {}

    Parameters

    Returns Web3SubscriptionManager<API, RegisteredSubs>

Properties

publicreadonlyregisteredSubscriptions

registeredSubscriptions: RegisteredSubs

publicreadonlyrequestManager

requestManager: Web3RequestManager<API>

Accessors

publicsubscriptions

  • get subscriptions(): Map<string, InstanceType<RegisteredSubs[keyof RegisteredSubs]>>
  • Will returns all subscriptions.


    Returns Map<string, InstanceType<RegisteredSubs[keyof RegisteredSubs]>>

Methods

publicaddSubscription

  • addSubscription(sub: InstanceType<RegisteredSubs[keyof RegisteredSubs]>): Promise<string>
  • Adds an instance of Web3Subscription and subscribes to it


    Parameters

    • sub: InstanceType<RegisteredSubs[keyof RegisteredSubs]>

    Returns Promise<string>

publicclear

  • clear(): void
  • Clears all subscriptions


    Returns void

publicremoveSubscription

  • removeSubscription(sub: InstanceType<RegisteredSubs[keyof RegisteredSubs]>): Promise<string>
  • Will clear a subscription


    Parameters

    • sub: InstanceType<RegisteredSubs[keyof RegisteredSubs]>

    Returns Promise<string>

publicsubscribe

  • subscribe<T>(name: T, args?: ConstructorParameters<RegisteredSubs[T]>[0], returnFormat?: DataFormat): Promise<InstanceType<RegisteredSubs[T]>>
  • Will create a new subscription


    Type parameters

    • T: string | number | symbol

    Parameters

    • name: T

      The subscription you want to subscribe to

    • optionalargs: ConstructorParameters<RegisteredSubs[T]>[0]

      Optional additional parameters, depending on the subscription type

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

    Returns Promise<InstanceType<RegisteredSubs[T]>>

    The subscription object

publicsupportsSubscriptions

  • supportsSubscriptions(): boolean
  • Check whether the current provider supports subscriptions.


    Returns boolean

    true or false depending on if the current provider supports subscriptions

publicunsubscribe

  • unsubscribe(condition?: ShouldUnsubscribeCondition): Promise<string[]>
  • Will unsubscribe all subscriptions that fulfill the condition


    Parameters

    • optionalcondition: ShouldUnsubscribeCondition

      A function that access and id and a subscription and return true or false

    Returns Promise<string[]>

    An array of all the un-subscribed subscriptions