inProgress-team / react-native-meteor

Meteor Reactivity for your React Native application :)
MIT License
693 stars 210 forks source link

Subscribe ready but returns null #292

Closed rgstephens closed 7 years ago

rgstephens commented 7 years ago

I can subscribe to a publication and can see with the ddp.on calls showing that the added and ready messages arrive as expected and they show the expected mongo objects for this subscription from the server. However, the resulting array of objects is always empty.

I'm using 1.2.0 with RN 0.48.4 and React 16.0.0.

const MeteorContainer = createContainer(() => {
  console.log("MeteorContainer,  userId: " + Meteor.userId());
  const keysSubscription = Meteor.subscribe("keys");
  return {
    meteorUser: Meteor.user(),
    meteorStatus: Meteor.status(),
    loggingIn: Meteor.loggingIn(),
    keysReady: keysSubscription.ready(),
    keyCount: Meteor.collection("keys").find().length,
    keys: Meteor.collection("keys").find()
  };
}, Keys);

I also tried enabling the cursoredFind option on the subscription but I get an error when I enable it and then try and do the fetch.

ExceptionsManager.js:65 _reactNativeMeteor2.default.collection(...).find(...).fetch is not a function
Nauzer commented 7 years ago

Not sure if it will make a difference, but I always pass an empty object into the find method.

Besides that - is your Collection really called 'keys' or is that only the publication name? I had similar behavior with a collection I named 'Teams' which I published with 'Teams' and 'TeamsList' publication. For the latter obviously the results could be found in the 'Teams' collection as well.

rgstephens commented 7 years ago

@Nauzer Thanks for the ideas! That got me headed down the right path.

Yes, my collection is called Keys and publication is called keys. The find should have been asking for Keys not keys. Changing to initial caps got me going.