Advertisement
Guest User

Untitled

a guest
Aug 13th, 2013
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. I have the following code in one of my view.js files (I've got one .html and one .js file for every "page"/route I have in my app). In this case it is the groups.js file:
  2.  
  3. Deps.autorun(function() {
  4. eventHandle = Meteor.subscribe("singleevent", Session.get('ehash'), function onComplete() {
  5. console.log('Deps: Single event loaded!');
  6. });
  7. groupsHandle = Meteor.subscribe("groups", Session.get('ehash'), function onComplete() {
  8. console.log('Deps: Groups loaded!');
  9. });
  10. });
  11.  
  12. In my template, I wrap basically everything in a helper called "dataLoaded", which does the following:
  13.  
  14. 'dataReady': function() {
  15. if(eventHandle.ready() && groupsHandle.ready()) {
  16. console.log('All data loaded!');
  17. singleevent = Events.find({ehash: Session.get('ehash')}).fetch()[0];
  18. return true;
  19. }
  20. }
  21.  
  22. Problem is: In many cases (sometimes 5 times in a row, sometimes I can make 10 reloads without any problems and then the error occurs), the two console.log()s inside the Deps.autorun DO show up, so (I hope this is correct) both subscriptions are loaded successfully and the data is ready.
  23.  
  24. But still, "All data loaded!" does NOT show up in my console, although, as of said, the subscriptions should be ready. Thus, in this case, dataReady does not return true and no content is displayed.
  25.  
  26. I use the latest stable release of Google Chrome on Mac.
  27. Also worth mentioning: I use the same variable names for my subscriptions in multiple view.js files ... I hope this is no problem?!
  28.  
  29. I just do not understand how this is possible.
  30.  
  31. Another thing: Does it make any difference if I do `if(eventHandle.ready && groupsHandle.ready)` or `if(eventHandle.ready() && groupsHandle.ready())`? I tried both versions but I can't really figure out if there is any difference. The error described above occured with both versions btw!
  32.  
  33. EDIT: Here is my code structure:
  34.  
  35. ![enter image description here][1]
  36.  
  37. ... and my file structure:
  38.  
  39. ![enter image description here][2]
  40.  
  41. --------------------------------------
  42.  
  43. EDIT 2:
  44.  
  45. In addition, I really do not understand how something like this can happen:
  46.  
  47. ![enter image description here][3]
  48.  
  49. How can "Events" be undefined inside this onSuccess function, which should only be called, when the data is ready from this subscription (provided by the "Events" collection)??
  50.  
  51. --------------------------------------
  52.  
  53. EDIT 3:
  54.  
  55. Do I have to call [this.ready()][4] manually in my publish function? I thought this happens automatically.
  56.  
  57. --------------------------------------
  58.  
  59. Anyone has any ideas on this issue? :-)
  60.  
  61. best regards P
  62.  
  63.  
  64. [1]: http://i.stack.imgur.com/JNzOb.png
  65. [2]: http://i.stack.imgur.com/Avc6N.png
  66. [3]: http://i.stack.imgur.com/HFZ3y.png
  67. [4]: http://docs.meteor.com/#publish_ready
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement