Created
January 9, 2018 19:48
-
-
Save intellix/c7a8c419b71ca9f257f9fb513d435105 to your computer and use it in GitHub Desktop.
Heap size differences
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
import { Component, ChangeDetectionStrategy } from '@angular/core'; | |
import { ActivatedRoute } from '@angular/router'; | |
import { Apollo } from 'apollo-angular'; | |
import { Observable } from 'rxjs/Observable'; | |
import { map, pluck, switchMap } from 'rxjs/operators'; | |
import { query, User, SummaryResponse } from './summary.graphql'; | |
@Component({ | |
selector: 'cw-summary', | |
templateUrl: './summary.component.html', | |
styleUrls: ['./summary.component.scss'], | |
changeDetection: ChangeDetectionStrategy.OnPush, | |
}) | |
export class SummaryComponent { | |
user$: Observable<User> = this.route.parent.params.pipe( | |
pluck('id'), | |
switchMap(id => { | |
return this.apollo.watchQuery<SummaryResponse>({ | |
query, | |
variables: { id }, | |
}).valueChanges; | |
}), | |
map(({ data }) => data.user), | |
); | |
constructor( | |
private apollo: Apollo, | |
private route: ActivatedRoute, | |
) { } | |
} |
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
import { Component, ChangeDetectionStrategy } from '@angular/core'; | |
import { ActivatedRoute } from '@angular/router'; | |
import { Apollo } from 'apollo-angular'; | |
import { Observable } from 'rxjs/Observable'; | |
import { map, pluck, switchMap } from 'rxjs/operators'; | |
import { query, User, SummaryResponse } from './summary.graphql'; | |
@Component({ | |
selector: 'cw-summary', | |
templateUrl: './summary.component.html', | |
styleUrls: ['./summary.component.scss'], | |
changeDetection: ChangeDetectionStrategy.OnPush, | |
}) | |
export class SummaryComponent { | |
user$: Observable<User>; | |
constructor( | |
apollo: Apollo, | |
route: ActivatedRoute, | |
) { | |
this.user$ = route.parent.params.pipe( | |
pluck('id'), | |
switchMap(id => { | |
return apollo.watchQuery<SummaryResponse>({ | |
query, | |
variables: { id }, | |
}).valueChanges; | |
}), | |
map(({ data }) => data.user), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
summary-1: 472 retained size
summary-2: 232 retained size