Learning to Use Monitor Builder: Supplying Data

A poll type data source is shown below. Within this poll you would likely perform some custom on- or off-chain data collection. Poll duration is also configured.

  .poll((subscribers: ResourceId[]) => {
    const sourceData: SourceData<YourDataType>[] = subscribers.map(
      (resourceId) => ({
        data: {
          cratio: Math.random(),
          healthRatio: Math.random(),
          resourceId,
        },
        groupingKey: resourceId.toString(),
      }),
    );
    return Promise.resolve(sourceData);
  }, Duration.fromObject({ seconds: 3 }))

A push type data source is describer in this example.

Last updated