devvit
devvit copied to clipboard
Custom Triggers
It could be useful to be able to emit custom triggers. This could allow one app to process some data and emit a trigger with that data for other apps to act on. It could also be used within the same app, but that doesn't seem as useful. I imagine it something like this:
function myFunc() {
{process some data}
const id: str = 'MyEventID';
const data: any = ...;
Devvit.emitCustomEvent(id,data);
}
Devvit.addTrigger({
event: 'CustomEvent',
onEvent: (event,context) => {
if (event.id !== 'MyEventID') {
return;
}
const data = event.data;
}
});
I hadn't looked at it until now, but in-app custom triggers is basically https://developers.reddit.com/docs/capabilities/realtime, except without the need for it to be real-time, and available everywhere.