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.

TdLoading Pipe or Directive when using an Angular async pipe

See original GitHub issue

Feature Request

TdLoading Pipe or Directive

When using an asynchronous pipe in conjunction with an *ngFor it would be nice for the TdLoading service to track the start and end of an XHR request to the remote server.

What is the expected behavior?

If I use the following snippet of code the TdLoading pipe or service should be able to start an infinite progress indicator.

When the remote call is complete and the object list is available to be iterated over the progress indicator should disappear.

<div *ngFor="let item of items | async | tdLoading">
   {{item.name}}
</div>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
trkbrkr2000commented, May 8, 2017

I think that this approach would leave the least amount of questions about what is going on. The syntax is readable and leaves no room for interpretation. This approach also implies the developer use one loading service per item placed on the page without having to declare a named element to be resolved when the observable is returned.

 <div *tdLoading="observable | async as items">
      <div *ngFor="let value of items">
        {{value}}
      </div>
 </div>

Or

<div *tdLoading="observable | async as value'">
      <div>{{value.name}}</div>
      <div>{{value.age}}</div>
</div>

Where as this approach <div *tdLoading="'name'; [new_input_here]: observable | async as items"> might leave someone wondering why they would need to use the string name in the configuration of the loading service when the contained element is the target item they want the loading service to mask while loading is in progress.


All the while I think that both approaches would provide great utility when binding to an observable data source.

1reaction
emoralesb05commented, May 8, 2017

Playing around with this, and i think it will be something like described before:

    <div *tdLoading="observable | async as items">
      <div *ngFor="let value of items">
        {{value}}
      </div>
    </div>

OR

    <div *tdLoading="observable | async as value'">
        <div>{{value.name}}</div>
        <div>{{value.age}}</div>
    </div>

Since when using the async pipe, what we get as input is null, and then once its resolved we get what it returned as input.

We can translate this as true or false (which will also be a way of using it)

Diving in more 🤓

Read more comments on GitHub >

github_iconTop Results From Across the Web

AsyncPipe - Angular
The async pipe subscribes to an Observable or Promise and returns the latest value it has emitted. ... It's also possible to use...
Read more >
Using the Async Pipe in Angular - Pluralsight
We can use the async pipe in Angular application by including the CommonModule which exports all the basic Angular directives and pipes, ...
Read more >
Several Ways to Use Async Pipes in Angular - Medium
Using ng-container and * ngIf Directive. There is an additional way. This is using CombineLatest, the RxJS operator.
Read more >
angular - problem binding pipe async inn custom directive input
I can see at least 2 possible ways of solving this. First. You can drop the use of a custom directive and rely...
Read more >
Async Pipe: How to use it properly in Angular - malcoded
Also, we will learn how to use it with interpolation data binding and different directives like *ngIf and *ngFor. Ready? Let's get started!...
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