// Dispatch dispatches a event by invoking callbacks concurrently and waits for them to finish.
Dispatch dispatches a event by invoking callbacks concurrently and waits for them to finish.
// Dispatch dispatches a event by invoking callbacks concurrently and waits for them to finish .
func (b *bus) DispatchAndWait(event *Event) {
	if actual, ok := b.callbacks.Load(event.Name); ok {
		var wg sync.WaitGroup
		for i := range actual.([]Callback) {
			h := (actual.([]Callback))[i]
			wg.Add(1)
			gofunc.GoFunc(context.Background(), func() {
				h(event)
				wg.Done()
			})
		}
		wg.Wait()
	}
}
func ( b * bus ) DispatchAndWait ( event * Event ) { if actual , ok := b . callbacks . Load ( event . Name ) ; ok { var wg sync . WaitGroup for i := range actual . ( [ ] Callback ) { h := ( actual . ( [ ] Callback ) ) [ i ] wg . Add ( 1 ) gofunc . GoFunc ( context . Background ( ) , func ( ) { h ( event ) wg . Done ( ) } ) } wg . Wait ( ) } }
Dispatch dispatches a event by invoking callbacks concurrently and waits for them to finish.
Dispatch dispatches a event by invoking callbacks concurrently and waits for them to finish .