You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want {to add custom hooks that run before or after blocks}
So that {I can enrich Jayvee without modifying the original source code}
User Acceptance Criteria
I can add custom hooks to specific block types via reference to the class
I can add custom hooks to specific block types via a boolean function with the param { type: string } (or slightly different if it fits better to the current implementation)
The arguments (meta, input, output data) for the hook functions are typed properly.
This may be disabled for hooks with a blocks array of size >1. Here, the types may remain unknown.
The implementation should be backwards compatible, i.e. the blocks argument should be optional.
Examples
import{HttpExtractor}from'...';myJayveeProgram.addPreBlockHook(myLambda,{blocks: [HttpExtractor],})// Or for custom blocks like composite blocks (they are not built-in)myJayveeProgram.addPreBlockHook(myLambda,{blocks: [HttpExtractor,({ type })=>type==='MyCustomCompositeBlock'],})
Notes
Try to keep it as simple as possible in regards to the implementation/design (which probably means it's not efficient as possible)
E.g., Map a missing list of blocks to [() => true]
E.g., Map a class that was given to the blocks array to a function internally (HttpExtractor => ({ type }) => type === HttpExtractor.type).
Definitions of Done
A PR has been opened and accepted
All user acceptance criteria are met
All tests are passing
The text was updated successfully, but these errors were encountered:
There is currently no HttpExtractor exported from the interpreter library. An alternative would be to use HttpExtractorExecutor, but this assumes every block type only has one executor. While this is currently true (afaik), it might change in the future.
Resulting from a discussion with @joluj: We decided to use strings to represent block type names. This weakens the static typing for the hooks themselves (a hook on TableTransformer wouldn't have a static parameter of type Table), but it keeps the implementation simple.
New example:
myJayveeProgram.addHook('preBlock',myLambda,{blocktypes: 'HttpExtractor',})// Or for custom blocks like composite blocks (they are not built-in)myJayveeProgram.addHook('preBlock',myLambda,{blocktypes: ['HttpExtractor','MyCustomCompositeBlock'],})
This is a follow-up issue of #633.
User Story
User Acceptance Criteria
I can add custom hooks to specific block types via reference to the class
I can add custom hooks to specific block types via a boolean function with the param
{ type: string }
(or slightly different if it fits better to the current implementation)The arguments (meta, input, output data) for the hook functions are typed properly.
blocks
array of size >1. Here, the types may remainunknown
.The implementation should be backwards compatible, i.e. the
blocks
argument should be optional.Examples
Notes
blocks
to[() => true]
blocks
array to a function internally (HttpExtractor
=>({ type }) => type === HttpExtractor.type
).Definitions of Done
The text was updated successfully, but these errors were encountered: