Skip to content
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

pipes that call functions #1510

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft

Conversation

svonworl
Copy link
Contributor

@svonworl svonworl commented Apr 22, 2022

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
Copy link

codecov bot commented Apr 22, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fd0e07c) 43.86% compared to head (9cc47a2) 43.86%.
Report is 348 commits behind head on develop.

❗ 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           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lgtm-com
Copy link

lgtm-com bot commented Apr 22, 2022

This pull request introduces 1 alert when merging 570d4f5 into fd0e07c - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@lgtm-com
Copy link

lgtm-com bot commented Apr 22, 2022

This pull request introduces 1 alert when merging a080006 into 59df8f0 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@sonarcloud
Copy link

sonarcloud bot commented Apr 22, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Apr 26, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant