Hi all,
I am using meteor 1.3 with react.
I have a collection called Model_Members where each doc has an object “viewsettings”.
I would like to run the function refreshLines() when the viewsettings.mapBounds field changes. The function refreshLines() calls a Meteor method which returns an array of lines within the map bounding box. These lines are put into a local collection on the client.
I am having trouble, because refreshLines() is not triggered when I change the mapBounds field in the server console: Like so:
db.model_members.update({},{$set:{‘viewsettings.mapBounds’:‘xxx’}})
Any advice would be greatly appreciated
‘’'
import { Meteor } from ‘meteor/meteor’;
import { createContainer } from ‘meteor/react-meteor-data’;
import { Model_Members } from ‘…/…/api/collections/model_members.js’;
import { MapPage } from ‘…/pages/mappage.jsx’;
Lines = new Mongo.Collection(null);
function refreshLines(modelId) {
Lines.remove({})
Meteor.call(‘lines.updatex’,modelId,(err, res) => {
if(res) {
console.log(“res”,res)
res.forEach((item) => {
Lines.insert(item);
});
} else {
console.log(“err”,err)
}
})
}
export default createContainer(props => {
const { modelId } = props.params
Meteor.subscribe(‘model_members.viewsettings’, modelId, function() {
const viewsettings = Model_Members.find({},{fields:{‘viewsettings.mapBounds’:1}});
viewsettings.observe({
changed: refreshLines(‘X3W’)
});
});
return {
lines: Lines.find().fetch()
};
}, MapPage);
‘’’