package festival_test import ( "context" "fmt" "git.golem15.com/golem15/summercms/modules/festival" ) // PostPublished is the event the acme.blog plugin fires after a post goes live. type PostPublished struct { Title string } func ExampleBus_Fire() { bus := festival.New() // in a plugin, use app.Events // acme.search and acme.notify extend acme.blog from their Boot steps. bus.Listen("acme.search", func(ctx context.Context, e PostPublished) error { fmt.Println("index", e.Title) return nil }) bus.ListenPriority("acme.notify", 10, func(ctx context.Context, e PostPublished) error { fmt.Println("notify subscribers of", e.Title) return nil }) // acme.blog fires the event; higher priorities run first. if err := bus.Fire(context.Background(), PostPublished{Title: "Hello"}); err != nil { fmt.Println(err) } // Output: // notify subscribers of Hello // index Hello }