Skip to content

Two active subscriptions for the same Event #193

@rylorin

Description

@rylorin

Hello,

If you setup 2 active subscriptions using the same event, but different callbacks, for example:

this.subscriptions.register<OpenOrder[]>(
      () => {
        this.api.reqOpenOrders();
      },
      undefined,
      [
        [EventName.openOrder, this.onOpenOrder],
        [EventName.orderStatus, this.onOrderStatus],
        [EventName.orderBound, this.onOrderBound],
        [EventName.openOrderEnd, this.onOpenOrderEnd],
      ],
      "getOpenOrders", // use same instance id each time, to make sure there is only 1 pending request at time
    );

and

this.subscriptions
        .register<OpenOrder[]>(
          () => {
            this.api.reqAllOpenOrders();
          },
          undefined,
          [
            [EventName.openOrder, this.onOpenOrder],
            [EventName.orderStatus, this.onOrderStatus],
            [EventName.orderBound, this.onOrderBound],
            [EventName.openOrderEnd, this.onOpenOrderComplete],
          ],
          "getAllOpenOrders", // use same instance id each time, to make sure there is only 1 pending request at time
        );

As the subscription registry maintains a Map with the EventName as key and a callback and it's subscriptions as entry:

  /** A Map containing the subscription registry, with event name as key. */
  private readonly entires = new IBApiNextMap<EventName, RegistryEntry>();

The second callback for the same EventName.openOrderEnd will be ignored (in favour of the first active subscription callback) leading to undesired behaviour.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions