Bonnie Brennan
and
Mateus Carniatto
Angular GDE
Angular Architect
ngHouston Founder
Angular Air Panelist
Angular Expert @ Riaktr
Angular Break the Ice Organizer
<ng-container *ngIf="(source$ | async) as data">
<my-component [data]="data"></my-component>
</ng-container>
export class SomeComponent implements OnDestroy {
private subs = new SubSink();
...
this.subs.sink = observable$.subscribe(...); // easy syntax
this.subs.add(observable$.subscribe(...)); // if you insist
this.subs.add( // can add multiple subcriptions
observable$.subscribe(...),
anotherObservable$.subscribe(...)
);
...
// Unsubscribe when the component dies
ngOnDestroy() {
this.subs.unsubscribe();
}
}
@Component({
selector: 'my-component',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
constructor(private http: HttpClient) {
}
ngOnInit(): void {
// auto completes and unsubscribes after the http request is completed
this.http.get('http://my-data-service/users').subscribe({ ... });
}
}
// from this
// (imports the whole library)
import * as _ from 'lodash' // 23.6kb
// to this
// (imports just the needed)
import chunk as _chunk from 'lodash-es/chunk' // 3kb
{
"configurations": {
"production": {
"budgets": [
{
"type": "bundle",
"name": "vendor",
"baseline": "750kb",
"warning": "100kb",
"error": "200kb"
}
]
}
}
}
a.k.a. The Sibling Rule
Matt
@c4rniatto
Bonnie
@bonnster75