From 44218ec4acde0cdfbe8dbca123dae04b45b3a1ce Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sat, 10 Sep 2022 20:05:10 +0200 Subject: [PATCH] with state in funcs --- builder.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/builder.go b/builder.go index 1ed42b4..4d8b4a3 100644 --- a/builder.go +++ b/builder.go @@ -3,9 +3,9 @@ package curre import "context" type FunctionalComponent struct { - InitFunc func(ctx context.Context) error - StartFunc func(ctx context.Context) error - StopFunc func(ctx context.Context) error + InitFunc func(fc *FunctionalComponent, ctx context.Context) error + StartFunc func(fc *FunctionalComponent, ctx context.Context) error + StopFunc func(fc *FunctionalComponent, ctx context.Context) error } func NewFunctionalComponent( @@ -16,19 +16,19 @@ func NewFunctionalComponent( func (fc *FunctionalComponent) Init(ctx context.Context) error { if fc.InitFunc != nil { - return fc.InitFunc(ctx) + return fc.InitFunc(fc, ctx) } return nil } func (fc *FunctionalComponent) Start(ctx context.Context) error { if fc.StartFunc != nil { - return fc.StartFunc(ctx) + return fc.StartFunc(fc, ctx) } return nil } func (fc *FunctionalComponent) Stop(ctx context.Context) error { if fc.StopFunc != nil { - return fc.StopFunc(ctx) + return fc.StopFunc(fc, ctx) } return nil }