Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PollingClient

This is a polling client that can be used to poll the status of long running tasks. It can be used as a replacement for Streaming when streaming topics are not available or when streaming handshakes are failing. Why wouldn't you want to use this? It can impact Salesforce API usage.

const options: PollingClient.Options = {
     async poll(): Promise<StatusResult>  {
      return Promise.resolve({ completed: true, payload: 'Hello World' });
    },
    frequency: Duration.milliseconds(10),
     timeout: Duration.minutes(1)
  };
const client = await PollingClient.create(options);
const pollResult = await client.subscribe();
console.log(`pollResult: ${pollResult}`);

Hierarchy

  • AsyncOptionalCreatable<Options>
    • PollingClient

Index

Classes

Interfaces

Properties

Methods

Properties

Protected logger

logger: Logger

Methods

init

  • init(): Promise<void>

subscribe

  • subscribe(): Promise<AnyJson>
  • Returns a promise to call the specified polling function using the interval and timeout specified in the polling options.

    Returns Promise<AnyJson>

Static create

  • create<P, T>(this: object, options?: P): Promise<T>
  • Asynchronously constructs and initializes a new instance of a concrete subclass with the optional options.

    Type parameters

    • P

    • T: AsyncOptionalCreatable<P>

    Parameters

    • this: object
    • Optional options: P

      An options object providing initialization params to the async constructor.

    Returns Promise<T>