tangle-network / gadget

A framework for building modular AVS and Tangle Blueprints: https://docs.tangle.tools/developers/blueprints.
https://tangle.tools
Apache License 2.0
12 stars 3 forks source link

[TASK] Event Listener Improvements + Docs + Wrapper Types #334

Open tbraun96 opened 1 week ago

tbraun96 commented 1 week ago

The newly created EventListener implementation should include easy-to-read developer-oriented documentation. Additionally, several wrapper types should be defined for common use cases, such as periodic listeners that call an inner listener at a set interval, and, an EventListener for substrate-based chains.

The job macro's EventListener support should also:

With this PR, when we run an EventListener, we do so by running .init().await on the codegen struct generated from the job macro:

        let x_square = blueprint::XsquareEventHandler {
            service_id: self.env.service_id.unwrap(),
            client: client.clone(),
            my_context: MyContext {
                additional_delay: 0,
            },
            signer,
        };

        x_square.init().await; <-- initializes **all listeners** attributed to this job, but does not wait for completion

The main function from issue #331 can support running multiple jobs, and in turn for each job, will automatically support potentially multiple event listeners.