Skip to content

Instantly share code, notes, and snippets.

@intellix
Created January 9, 2018 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save intellix/c7a8c419b71ca9f257f9fb513d435105 to your computer and use it in GitHub Desktop.
Save intellix/c7a8c419b71ca9f257f9fb513d435105 to your computer and use it in GitHub Desktop.
Heap size differences
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,
) { }
}
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),
);
}
}
@intellix
Copy link
Author

intellix commented Jan 9, 2018

summary-1: 472 retained size
summary-2: 232 retained size

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment