i'm completely new to MeteorJS, just looking at demos and poking around. it is possible that i'm just missing something really basic. i'm using meteor with angular-ui-router. if i start with a state that loads data into a controller, i run into issues because DDP has not initialized yet. this is similar to what was described in Meteor: How can I tell when the database is ready?
relevant part of routing config:
resolve: {
location: ($stateParams) => {
console.log('find', $stateParams);
let handle = setInterval(function () {
console.log(Meteor.status().connected, Meteor.status().status);
console.log( !!Locations.findOne({code: $stateParams.code}) ? 'found' : 'not found' );
}, 100);
setTimeout(function () {
clearInterval(handle);
}, 2000);
console.log(Meteor.status().connected, Meteor.status().status);
return Locations.findOne({code: $stateParams.code});
}
}
and the output is
false "connecting"
false "connecting"
not found
true "connected"
not found
true "connected"
not found
true "connected"
found
true "connected"
found
my question is: do i understand correctly that the problem here is that for things to work as expected they must happen in this sequence:
- web socket connection is initiated
- web socket connection is ready to use
- minimongo is refreshed
- collection.findOne
and 4. is running before 3? if so, what is the suggested workaround?
cross-post: https://github.com/meteor/meteor/issues/9127