Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2-Meteor zone() method

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?

like image 663
lightbringer Avatar asked May 21 '26 14:05

lightbringer


1 Answers

According to the article you linked:

.zone() is a wrapper for the regular Observable that 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.

like image 88
Andrew Hill Avatar answered May 25 '26 22:05

Andrew Hill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!