Skip to content

Packages  ›  trotsky  ›  StepWait

StepWait class

Represents step that introduces a delay before proceeding to the next step.

Signature:

typescript
export declare class StepWait<P = StepBuilder, C = null, O = null> extends Step<P, C, O>

Extends: Step<P, C, O>

Example 1

Add a delay between actions:

ts
await Trotsky.init(agent)
  .searchPosts({ q: "typescript" })
  .take(5)
  .each()
  .like()
  .wait(2000) // Wait 2 seconds between likes
  .run()

Example 2

Rate limit API calls:

ts
await Trotsky.init(agent)
  .actors(["alice.bsky.social", "bob.bsky.social", "carol.bsky.social"])
  .each()
  .follow()
  .wait(3000) // Wait 3 seconds between follows
  .run()

Constructors

Constructor

Modifiers

Description

(constructor)(agent, parent, duration)

Initializes the StepWait instance with the given duration.

Properties

Property

Modifiers

Type

Description

_duration

protected

number

The duration of the delay in milliseconds.

Methods

Method

Modifiers

Description

apply()

Applies the step logic to introduce a delay. The process is paused for the duration specified in _duration.

clone(rest)

Clones the current step and returns a new instance with the same parameters.