Hello,
I’m working with Angular2 and I’m trying to make a single object Observable.
For a list, it’s ok :
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { MeteorObservable } from 'meteor-rxjs';
import { Example } from '../../../../both/models/example.model';
import { Examples } from '../../../../both/collections/examples.collection';
import template from './example-list.component.html'
@Component({
selector: 'example-list',
template
})
export class ExampleListComponent implements OnInit {
examples: Observable<Example[]>;
public constructor() {
}
ngOnInit() {
this.examples = Examples.find({}).zone();
}
}
And then, I can loop on examples in the template side.
But how to deal with single object ?
How can i retrieve them from a collection and make each update reactive from a client to another ?
I can’t figure it with a “findOne”. This doesn’t work :
export class ExampleListComponent implements OnInit {
example: Observable<Example>;
public constructor() {
}
ngOnInit() {
this.example = Examples.findOne({});
}
}
What is the right way to do this ?
Thanks !!!
Fabio