Skip to main content

Controlling the runner

To interact with the runner you need a reference to the runner instance. That allows you to perform actions like pause, stop and start the runner. You can also retrieve the current state of the runner. All possible functions and properties are in the reference.

tip

If you are using the React component of the runner, have a look here.

🕹ī¸ Retrieving the runner reference​

The runner reference is retrieved from the run function. This is an async function, so you should use await or the promise to retrieve the reference.

Using await​

In a modern browser environment, you can use await to obtain the reference.

import { run } from "@tripetto/runner-autoscroll";

// Retrieve the runner reference using await
const runner = await run({
definition: /* Supply your form definition here */,
});

// Now we can interact with the runner
runner.restart();

Using the promise​

If you can't use await, then use the promise.

import { run } from "@tripetto/runner-autoscroll";

// Retrieve the runner reference using promise
run({
definition: /* Supply your form definition here */,
}).then((runner) => {
// Now we can interact with the runner
runner.restart();
});

Using React​

If you use the React component of the runner, you can use the controller property to retrieve the reference.

import { AutoscrollRunner, IAutoscrollController } from "@tripetto/runner-autoscroll";
import { useRef } from "react";

function ExampleApp() {
const controllerRef = useRef<IAutoscrollController>();

return (
<AutoscrollRunner
definition={/* Supply your form definition here */}
controller={controllerRef}
/>
);
}

📖 Reference​

Have a look at the complete autoscroll runner API reference for detailed documentation. In the examples above, the following symbols were used: