Developers
Blueprint SDK Event Listeners
Tangle Job Call Listener

Tangle Job Call Listeners

Tangle Job Call Listeners are a powerful feature in the Gadget SDK that allow your blueprint to react to job calls on the Tangle network. These listeners leverage Rust's async capabilities and the tokio runtime to efficiently handle incoming job requests.

Overview

Tangle Job Call Listeners enable your blueprint to:

  1. Listen for specific job calls on the Tangle network
  2. Execute custom logic in response to job calls
  3. Process and validate job parameters

Tangle Job Call Listeners are particularly useful for tasks such as:

  • Executing on-chain operations based on job requests
  • Validating and processing data submitted through jobs
  • Triggering off-chain actions in response to on-chain events
  • Implementing complex business logic that integrates with the Tangle network

These listeners form a crucial part of Tangle's native job system, allowing blueprints to interact seamlessly with the broader Tangle ecosystem and respond to network events in real-time.

TangleEventListener

The TangleEventListener is a type that listens to the Tangle network for events. This is a required type if you expect your application to use the tangle network to listen to jobs.

The TangleEventListener is already implemented and ready to use. Simply register it in the job macro, and your application will automatically work with the Tangle network.

Service pre/post processors

The SDK also provides a ready-to-use pre-processor and post-processor for the JobCalled event on Tangle. The pre-processor destructures the arguments of blueprint jobs so that jobs can be executed with the arguments they are defined with. The post-processors

Pre-processor

The pre-processor for Tangle job calls handles the following tasks:

  1. Extracts and validates the job parameters from the raw event data
  2. Deserializes the parameters into the expected types
  3. Prepares the data for processing by the job handler

Post-processor

The post-processor for Tangle job calls handles the following tasks:

  1. Takes the output from the job execution
  2. Formats and prepares the result for on-chain storage
  3. Handles any cleanup or finalization required after job execution