ReceiveContext returns the next event from the channel or returns nil when the context is done.
(ctx context.Context)
| 62 | |
| 63 | // ReceiveContext returns the next event from the channel or returns nil when the context is done. |
| 64 | func (ch Channel) ReceiveContext(ctx context.Context) Event { |
| 65 | select { |
| 66 | case evt := <-ch: |
| 67 | return evt |
| 68 | case <-ctx.Done(): |
| 69 | return nil |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | // ContextHandler delivers events to the Handler as long as ctx.Err() is non-nil. |
| 74 | func ContextHandler(ctx context.Context, handler Handler) Handler { |