Open
Conversation
Contributor
piyapan039285
left a comment
There was a problem hiding this comment.
very good krub :) I suggest to add more topics in comment.
Comment on lines
+131
to
+157
| ### With AsyncPipe | ||
| We don't need to worry about memory leaks problem because it unsubscribes automatically. | ||
| ```typescript{% raw %} | ||
| @Component({ | ||
| selector: 'app-foo', | ||
| template: ` | ||
| <ng-container *ngIf="people$ | async as people"> | ||
| <div *ngFor="let person of people"> | ||
| <p>{{ person.firstName }} {{ person.lastName }}</p> | ||
| </div> | ||
| </ng-container> | ||
| ` | ||
| }) | ||
| export class FooComponent implements OnInit { | ||
| people$: Observable<People[]>; | ||
|
|
||
| constructor(private peopleService: PeopleService) { } | ||
|
|
||
| ngOnInit() { | ||
| this.people$ = this.peopleService.getPeople().pipe( | ||
| tap(people => { | ||
| // do something after subscribe | ||
| }) | ||
| ); | ||
| } | ||
| }{% endraw %} | ||
| ``` No newline at end of file |
Contributor
There was a problem hiding this comment.
I think we should add sub topic about "Do not use function with async pipe" because it can create infinite loop.
Many people have this problem. For example
earthpyy
requested changes
Aug 3, 2021
Member
earthpyy
left a comment
There was a problem hiding this comment.
Cool krub. But there are some changes might need to resolve krubb.
| When you want to display the data in another format, but still want to keep the raw format data. | ||
|
|
||
| ### Don't do this | ||
| ```typescript{% raw %} |
Member
There was a problem hiding this comment.
I'm not sure if it should includes {% raw %} and {% endraw %} krub?
| } | ||
| }{% endraw %} | ||
| ``` | ||
| If you do like above, the function `myFormatData` will be executed every time Angular detects a change (every keystroke or mouse movement), so **it affect to the performance** if that function has a lot process inside. |
Member
There was a problem hiding this comment.
Suggested change
| If you do like above, the function `myFormatData` will be executed every time Angular detects a change (every keystroke or mouse movement), so **it affect to the performance** if that function has a lot process inside. | |
| If you do like above, the function `myFormatData` will be executed every time Angular detects a change (every keystroke or mouse movement), so **it affect the performance** if that function has a lot of processes inside. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.