1.0.3 • Published 4 months ago

@anyit/cfg-interval-trigger v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Interval trigger

The IntervalTrigger class is a custom trigger implementation that extends the ValueProviderTrigger class from the @anyit/cfg library. It provides a way to trigger updates regularly, allowing you to reload configuration items in your application periodically.

Constructor

constructor(args: IntervalTriggerArgs)
  • args.interval (optional): The time interval in seconds at which the trigger should emit the update event. The default value is fetched from the process.env.CFG_TRIGGER_INTERVAL property.

Methods

start(): Promise<void>

Starts the interval trigger. The trigger will emit the update event at the specified interval.

stop(): Promise<void>

Stops the interval trigger. The trigger will no longer emit the update event.

Usage

To use the IntervalTrigger, first, you need to create an instance of the trigger by providing the desired interval:

import { IntervalTrigger } from '@anyit/cfg-interval-trigger';

const triggerIntervalInSeconds = 10; // Set the desired interval in seconds
const intervalTrigger = new IntervalTrigger({ interval: triggerIntervalInSeconds });

Then, you can use the intervalTrigger instance as the trigger for the value provider, which can be configured to use triggers. Please, see the example here.

1.0.3

4 months ago

1.0.2

5 months ago

1.0.1

10 months ago

1.0.0

10 months ago