mirror of
https://github.com/IBM/fp-go.git
synced 2025-06-23 00:27:49 +02:00
12 lines
478 B
Go
12 lines
478 B
Go
package readerioeither
|
|
|
|
import (
|
|
G "github.com/IBM/fp-go/context/readerioeither/generic"
|
|
)
|
|
|
|
// WithResource constructs a function that creates a resource, then operates on it and then releases the resource
|
|
func WithResource[R, A, ANY any](onCreate ReaderIOEither[R], onRelease func(R) ReaderIOEither[ANY]) func(func(R) ReaderIOEither[A]) ReaderIOEither[A] {
|
|
// wraps the callback functions with a context check
|
|
return G.WithResource[ReaderIOEither[A]](onCreate, onRelease)
|
|
}
|