Skip to content

Commit

Permalink
feat: Event group (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
lesleysin authored Feb 16, 2024
1 parent fe02b32 commit f0aee4e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/duit_core/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const (
navigation eventType = "navigation"
openUrl eventType = "openUrl"
custom eventType = "custom"
sequenced eventType = "sequenced"
grouped eventType = "grouped"
)

type Event struct {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
}
}

0 comments on commit f0aee4e

Please sign in to comment.