question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add JoinPipe to @angular/common

See original GitHub issue

Which @angular/* package(s) are relevant/releated to the feature request?

common

Description

In component templates, it’s common to join an array of data with some separator:

<p>{{ myData.join(', ') }}</p>

But function calls are evaluated every change detection cycle, so this could incur a hefty performance cost for large arrays. In those cases, a pipe could improve the performance of the operation.

Proposed solution

@angular/common should offer a JoinPipe that accepts an Array as input and returns the result of Array.prototype.join called with a given separator (, by default, matching the spec).

Alternatives considered

Applications can create a JoinPipe if they need it (large applications have probably done this already). But this could result in many different implementations of the pipe in the wild, several of which might unintentionally reimplement Array.prototype.join, resulting in unnecessary code shipped to users. A standard implementation is preferred.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:22
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
petebacondarwincommented, Oct 5, 2021

While it is true that a join pipe is fairly common and would benefit from being in a shared package, this could be said for a number of other similar operations. There are already libraries out there that offer this, which application developers could leverage. Consider https://fknop.gitbook.io/angular-pipes/documentation/array for example. This library has dozens of pipes for many scenarios.

0reactions
angular-automatic-lock-bot[bot]commented, Aug 4, 2022

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transforming Data Using Pipes - Angular
With a pure pipe, Angular ignores changes within composite objects, such as a newly added element of an existing array, because checking a...
Read more >
Why I have to put @angular/common pipes in the providers ...
My question is why I have to add these pipes in providers array and not the custom pipe(coded by me). – Keryanie. Feb...
Read more >
[Tutorial] How to create your own Angular pipe?
Now let's resist that urge and create a custom pipe instead. The first step is to generate your pipe using Angular CLI: ng...
Read more >
How To Use Angular Pipes in Components & Service ts files
Import DatePipe from @angular\common in app.module.ts file; Add the DatePipe to provider array. Inject the DatePipe in component constructor ...
Read more >
Top 5 @angular/common Code Examples - Snyk
Learn more about how to use @angular/common, based on @angular/common code examples created from the most popular ... Add click event to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found