There is a way to do this?
pedrolucasoliva opened this issue · comments
Im trying to insert insert a new Entity (document) at mongo, but before I need call a meteor method to catch some sequence to it:
public create(t: T): Observable<string> {
return MeteorObservable.call("getSequence", this.service).map(seq => {
t.seq = seq.padding;
return this.collection.insert(t);
});
}
I have been in trouble with the return of Observable.
Someone did it before?
ps:
this.collection = export const Entities = new MongoObservable.Collection("entities");
Try this.collection.collection.insert
if it exists
RxJS observables won't fire unless you subscribe them. So, this is not an issue related to meteor-rxjs
.
You can try to do like below;
public create(t: T): Observable<string> {
return MeteorObservable.call("getSequence", this.service).map(seq => {
t.seq = seq.padding;
return this.collection.insert(t);
}).subscribe(returnOfInsertion => {});
}
Note that; the mutation on external variable inside map
is not recommended because it will be side effect. You can learn more using RxJS Documentation.