In the angular2-meteor tutorial step3, we use a zone method. Code:
import { Component } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Parties } from '../../both/collections/parties.collection';
...some lines skipped...
template
})
export class AppComponent {
parties: Observable<any[]>;
constructor() {
this.parties = Parties.find({}).zone();
}
}
What exactly does Parties.find({}).zone() do?
According to the article you linked:
.zone()is a wrapper for the regularObservablethat connects the collections changes to the view using the Component's Zone.
For more information, here is an article that goes in depth into what Zones are in Angular 2.
Essentially, Parties.find({}).zone() will .find() all data in the Parties collection and connect that data to the components Zone. Since the mongo collection is a reactive data source, this should allow the component to reactively update its data as the data is updated in the Mongo collection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With