is using custom pipe in angular for httprequests discouraged?

129 Views Asked by At

i came across this documentation on angular pipe.

  • i tried out custom pipes without ajax calls(transformations like touppercase,tolowercase) and i receive expected results.
  • i tried out custom pipes with ajax call as mentioned in the documentation, and here is my observation.

logic in pipe class(impure pipe) (code copied from the documentation linked to this post) enter image description here

logic in template (code copied from the documentation linked to this post) enter image description here

output enter image description here

The output makes me to think about few things

  • is it recommended to use custom pipes for http calls based on the results i have posted above?
  • if i had not used the condition in line15,22 to 26 then the http calls are triggered infinite times. This example mentioned in this documentation doesn't make any sense to me for practical use(production use). why not remove this example and discourage from using this approach? or am i missing to understand some concepts here? please let me know
  • When i use the condition in line15,22 to 26 then the http call is invoked only once, but the customPipe gets invoked few additional number of times. why is that? No objects/variables in components (except for logic in pipe component) were updated to trigger the change detection
0

There are 0 best solutions below