dockstore-ui2
dockstore-ui2 copied to clipboard
pipes that call functions
Description This draft PR explores a technique that harnesses Angular pipes and associated change detection infrastructure to efficiently call functions from our Angular templates.
This PR creates two pipes: function
, and method
.
The function
pipe binds its first argument as this
to its second argument, which is a function. The bound function is then called, with the first argument being the pipe input value, and the remaining pipe arguments being the additional function arguments. For example, the Angular expression {{ org | function: this:brace }}
maps to the function call this.brace(org)
The method
pipe binds the pipe input value as this
to its first argument, which is a function. The bound function is then called, with the remaining pipe arguments. For example, the Angular expression {{ org | method: org.getLink }}
maps to the method call org.getLink()
. A more advanced implementation would also support a string as the first argument, which would name a field of the piped value, and get eval
-ed to a function value at run time.
All the example invocations in the PR don't do anything useful at present, and two are broken.
This is a very rough proof-of-concept, not production ready, and should not be merged.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
fd0e07c
) 43.86% compared to head (9cc47a2
) 43.86%. Report is 348 commits behind head on develop.
:exclamation: Current head 9cc47a2 differs from pull request most recent head ff58726. Consider uploading reports for the commit ff58726 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## develop #1510 +/- ##
========================================
Coverage 43.86% 43.86%
========================================
Files 312 312
Lines 9378 9378
Branches 2245 2245
========================================
Hits 4114 4114
Misses 3433 3433
Partials 1831 1831
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This pull request introduces 1 alert when merging 570d4f51d09604f68adf064d5704b34464756587 into fd0e07c6d3d0e81675568ff21e23f8272fe7d543 - view on LGTM.com
new alerts:
- 1 for Unused variable, import, function or class
This pull request introduces 1 alert when merging a080006a7f82e3e8d1e4b18b994779c24f002469 into 59df8f027cb4e93e568ca8098f2974252fd85ee2 - view on LGTM.com
new alerts:
- 1 for Unused variable, import, function or class
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
1 Code Smell
No Coverage information
0.0% Duplication
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
1 Code Smell
No Coverage information
0.0% Duplication