From 2fcdc9158791b5980a3e89bb37c4d3a1437ffe7b Mon Sep 17 00:00:00 2001 From: a Date: Sat, 26 Mar 2022 21:23:36 -0500 Subject: [PATCH] EVEN MORE POWER --- examples/generic_pr/main.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/generic_pr/main.go b/examples/generic_pr/main.go index 109804d..cb0246a 100644 --- a/examples/generic_pr/main.go +++ b/examples/generic_pr/main.go @@ -34,6 +34,12 @@ func (_ *RequestContext[T]) Do() func(r *RequestContext[T]) *RequestContext[T] { } } +func (_ *RequestContext[T]) FilterErr() func(r *RequestContext[T]) bool { + return func(r *RequestContext[T]) bool { + return r.err == nil + } +} + type someResult struct { Title string `json:"title"` Id int `json:"id"` @@ -47,9 +53,7 @@ func main() { req: *r, } } - results := lambda.Filter(parallel.Map(requests, requests[0].Do(), 4), func(r *RequestContext[someResult]) bool { - return r.err == nil - }) + results := lambda.Filter(parallel.Map(requests, requests[0].Do(), 4), requests[0].FilterErr()) for _, v := range results { log.Printf("%s", v) }