devvit icon indicating copy to clipboard operation
devvit copied to clipboard

Custom Triggers

Open Yay295 opened this issue 11 months ago • 1 comments

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;
    }
});

Yay295 avatar Jan 01 '25 20:01 Yay295

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.

Yay295 avatar Feb 21 '25 07:02 Yay295