From fabd87a6c21f3a9c9d2c6a2d950bf02eedbe2bb0 Mon Sep 17 00:00:00 2001 From: lesleysin Date: Fri, 16 Feb 2024 21:02:42 +0200 Subject: [PATCH] Added new events --- pkg/duit_core/event.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pkg/duit_core/event.go b/pkg/duit_core/event.go index 6025fb7..76aefa5 100644 --- a/pkg/duit_core/event.go +++ b/pkg/duit_core/event.go @@ -8,6 +8,8 @@ const ( navigation eventType = "navigation" openUrl eventType = "openUrl" custom eventType = "custom" + sequenced eventType = "sequenced" + grouped eventType = "grouped" ) type Event struct { @@ -41,6 +43,21 @@ type customEvent struct { Extra map[string]interface{} `json:"extra,omitempty"` } +type SequencedEvent struct { + Delay int `json:"delay"` + Event interface{} `json:"event"` +} + +type sequencedEventGroup struct { + Event + Events []*SequencedEvent `json:"events"` +} + +type commonEventGroup struct { + Event + Events []interface{} `json:"events"` +} + // NewUpdateEvent creates a new update event. // // It takes a map of updates as a parameter. @@ -91,3 +108,15 @@ func NewCustomEvent(key string, extra map[string]interface{}) *customEvent { Extra: extra, } } + +func NewSequencedEventGroup(events []*SequencedEvent) *sequencedEventGroup { + return &sequencedEventGroup{ + Events: events, + } +} + +func NewCommonEventGroup(events []interface{}) *commonEventGroup { + return &commonEventGroup{ + Events: events, + } +}