aboutsummaryrefslogtreecommitdiff
path: root/mixins.go
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@mail.ru>2019-06-15 10:20:37 +0300
committerAlexander Kiryukhin <a.kiryukhin@mail.ru>2019-06-15 10:20:37 +0300
commit741cf397a9150a8f76b8f74289b1dde8aaa43d02 (patch)
tree66a64d97e247b57b37d82493eb307d1bf64c7490 /mixins.go
parentc691d422395cb72283512d8956a255db10b70b44 (diff)
WIP: Added lifecycle mixin
Removed hooks
Diffstat (limited to 'mixins.go')
-rwxr-xr-xmixins.go14
1 files changed, 14 insertions, 0 deletions
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}
+}