Allow custom card functions in modules #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allows app developers to pass card functions to modules as arguments.
Demonstration
Example app demonstrating use of locally defined card function:
example app
Also works with card function defined in another package (not shown).
Rationale
Currently each module has a hard-coded card function so the module developer has full control over what is added to the report. Neither the app user, nor the app developer has any influence on this.
Being able to redefine the card function is a valid use case.
Scoping Consideration
Current card functions are defined within the module server functions because they rely heavily on bindings that exist in the execution environment of the server function. In order for a function defined elsewhere to be able to access those bindings, a function is introduced,
hydrate_function.hydrate_functionchanges the enclosing environment of a function (here, a card function) to bring another frame into scope. It can also add other bindings to the funciton's enclosure.Implementation
<module_name>_card_function.card_functionformal argument. If not provided, falls back to the corresponding card function for the module.hydrate_functionto extend its scope to include the module server function's execution environment. This call is identical in all modules:card_function <- hydrate_function(card_function, with_filter, filter_panel_api).NOTE
This is a proof of concept, changes have only been made to
tm_g_distribution.Progress