asaskevich / EventBus

[Go] Lightweight eventbus with async compatibility for Go
MIT License
1.74k stars 220 forks source link

added publish async #1

Closed bennAH closed 9 years ago

bennAH commented 9 years ago

func slowCalculator(a, b int) { time.Sleep(3 * time.Second) fmt.Printf("%d\n", a + b) }

bus.Subscribe("main:slow_calculator", slowCalculator); wait := bus.PublishAsync("main:slow_calculator", 30, 70); fmt.Println("waiting for result")

// uncomment next 3 lines for awkward pause fmt.Println("start: do some stuff while waiting for a result") time.Sleep(2 * time.Second) mt.Println("end: do some stuff while waiting for a result")

wait.Wait();