Events Reference

The library emits events at key points in the task lifecycle. Subscribe to them to update your UI or trigger side effects in response to task state changes.

Subscribing to events

import { Events } from 'make-traffic-integration-core';

taskManager.subscribe(Events.TaskClaimSucceed, (task) => {
  // handle successful claim
});

Unsubscribing

Always unsubscribe listeners when they are no longer needed to prevent memory leaks:

const handler = (task) => { /* ... */ };

taskManager.subscribe(Events.TaskClaimSucceed, handler);

// later, when the component unmounts or the listener is no longer needed:
taskManager.unsubscribe(Events.TaskClaimSucceed, handler);

Available events

Event
Trigger
Callback argument

Events.TaskClaimSucceed

A task was successfully claimed (completed)

The claimed Task object

Events.TaskClaimFailed

A claim attempt failed

The Task object that failed

Events.TaskProcessed

A task was successfully processed

The processed Task object

Example — showing a reward notification

Example — handling claim failures

Last updated