-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BailHook default handler #33
Conversation
} | ||
} | ||
|
||
default?.invoke(p1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this'd be return default?.invoke(p1)
@@ -6,16 +6,18 @@ public sealed class BailResult<T> { | |||
public class Continue<T> : BailResult<T>() | |||
} | |||
|
|||
public abstract class SyncBailHook<F : Function<BailResult<R>>, R> : SyncBaseHook<F>("SyncBailHook") { | |||
protected fun call(invokeWithContext: (F, HookContext) -> BailResult<R>): R? { | |||
public abstract class SyncBailHook<T, F : (HookContext, T) -> BailResult<R>, R> : SyncBaseHook<F>("SyncBailHook") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't assume arity here. This is explicitly Function
, because that type is arity-less. I'm not sure we need to change anything in the base definition.
public abstract class SyncBailHook<F : Function<BailResult<R>>, R> : SyncBaseHook<F>("SyncBailHook") { | ||
protected fun call(invokeWithContext: (F, HookContext) -> BailResult<R>): R? { | ||
public abstract class SyncBailHook<T, F : (HookContext, T) -> BailResult<R>, R> : SyncBaseHook<F>("SyncBailHook") { | ||
protected fun call(invokeWithContext: (F, HookContext) -> BailResult<R>, default: ((T) -> Unit)? = null, p1: T): R? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type of default
would probably be F
. If we don't want the return type to be bounded to BailResult
, then we'd need to add another type param for the SyncBailHook
to capture the type of the default F
.
processor/src/main/kotlin/com/intuit/hooks/plugin/codegen/Poet.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Jeremiah Zucker <zucker.jeremiah@gmail.com>
🚀 PR was released in |
What Changed
Added a default handler to SyncBailHook
call
to automatically handle non-bail casesWhy
Provide a default behaviour for when all the taps continue
Todo:
Release Notes
Allows for
SyncBailHook
to call with a default handler for when the taps do not bail and return nothing📦 Published PR as canary version:
0.14.1-canary.33.352-SNAPSHOT