简体   繁体   English

Angular2-Meteor zone() 方法

[英]Angular2-Meteor zone() method

In the angular2-meteor tutorial step3 , we use a zone method.在 angular2-meteor 教程step3 中,我们使用了 zone 方法。 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? Party.find({}).zone() 到底是做什么的?

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. .zone()是常规Observable的包装器,它使用组件的 Zone 将集合更改连接到视图。

For more information, here is an article that goes in depth into what Zones are in Angular 2.有关更多信息, 这里有一篇文章深入介绍了 Angular 2 中的区域。

Essentially, Parties.find({}).zone() will .find() all data in the Parties collection and connect that data to the components Zone.从本质上讲, Parties.find({}).zone().find()中的所有数据Parties收集和数据连接组件区。 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.由于 mongo 集合是一个响应式数据源,这应该允许组件在 Mongo 集合中更新数据时响应式更新其数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM