Departure Labs Simple Events
A simple and fun library for publishing canister events to subscribers! 🎉
Please note that our implementation is not optimized for pushing large volumes of events or retrying on failures. However, it is still a great option for canisters with a few subscribers who need to share non-critical information. Got that? Okay, let's get started!
Publishing Events
To publish an event, first derive CandidType, Serialize, Deserialize traits for your event struct, and then implement SimpleEvent trait on it.
Then, add a subscriber using the add_subscriber function:
add_subscriber;
Finally, publish an event using the publish_event function:
publish_event;
Consuming Events
To consume events, add the following update method to your canister:
Next, implement logic to determine the type of incoming event: