From 741cf397a9150a8f76b8f74289b1dde8aaa43d02 Mon Sep 17 00:00:00 2001 From: Alexander Kiryukhin Date: Sat, 15 Jun 2019 10:20:37 +0300 Subject: WIP: Added lifecycle mixin Removed hooks --- mixins.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'mixins.go') diff --git a/mixins.go b/mixins.go index 6688f36..1344d07 100755 --- a/mixins.go +++ b/mixins.go @@ -58,3 +58,17 @@ func WithErrChan() *MixinErrChan { func (o MixinErrChan) apply(r *Rutina) { r.errCh = make(chan error, 1) } + +type LifecycleListener func(event Event, routineID int) + +type LifecycleMixin struct { + Listener LifecycleListener +} + +func (l LifecycleMixin) apply(r *Rutina) { + r.lifecycleListener = l.Listener +} + +func WithLifecycleListener(listener LifecycleListener) *LifecycleMixin { + return &LifecycleMixin{Listener: listener} +} -- cgit v1.2.3