summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/internal/pubsub/events.go
blob: e3910f9f5a7e065a4b0f18252060e5c573c3aca8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package pubsub

import "context"

type EventType string

const (
	EventTypeCreated EventType = "created"
	EventTypeUpdated EventType = "updated"
	EventTypeDeleted EventType = "deleted"
)

type Event[T any] struct {
	Type    EventType
	Payload T
}

type Subscriber[T any] interface {
	Subscribe(ctx context.Context) <-chan Event[T]
}

type Publisher[T any] interface {
	Publish(eventType EventType, payload T)
}