Reputation: 181
My Meteor application, which up until recently was working fine, recently stopped working despite there having been no code changes to the application. I've confirmed the issue exists on three different machines with two different operating systems, so I don't think it's a hardware/software issue.
The primary issue (yes, there's more than one issue) is that my subscription isn't recognized as 'ready' even though the publish has been marked as ready and my records are available in the client.
Here's my code:
Publish:
Meteor.publish 'tickets', (selectedSquad) ->
self = this
unformattedTickets = [ array of objects coming from JIRA API ]
_(unformattedTickets).forEach (issue) ->
doc =
normalizedColumn1: issue.fields.col
...
self.added 'tickets', Random.id(), doc
console.log 'publish ready'
self.ready()
Subscribe:
Tracker.autorun ->
@ticketSubscriptionHandle = Meteor.subscribe('tickets', Session.get('selectedSquad'))
Autorun for homepage:
Tracker.autorun ->
if ticketSubscriptionHandle.ready()
console.log 'ready'
doSomething()
I can see in my server 'publish ready', I can query Tickets.find()
in my console, yet ticketSubscriptionHandle.ready()
returns false, 'ready' isn't logged and doSomething()
doesn't run.
As far as I can tell I'm using subscriptions/autorun exactly as specified in the docs. I also don't understand how this could have possibly stopped working without modifying the code or the version of meteor being used.
If you want to see the complete code base, it's available on GitHub at https://github.com/jprince/kanburn
Any help would be appreciated.
Upvotes: 2
Views: 1423
Reputation: 8345
This is not an answer, but it may help you.
Note that the following code:
Tracker.autorun ->
@ticketSubscriptionHandle = Meteor.subscribe('tickets', Session.get('selectedSquad'))
must be executed before the following code:
Tracker.autorun ->
if ticketSubscriptionHandle.ready()
console.log 'ready'
doSomething()
Is that the case? And even if it is, there's still a problem. When you execute Session.set('selectedSquad', "a-new-value")
, the first autorun will re-run. You're expecting the other autorun to re-run as well, right? It won't, since ticketSubscriptionHandle
isn't is a reactive variable.
Upvotes: 1