我有以下代码:
GetPublication = new Meteor.Collection 'get-publication'
Meteor.autorun ->
Meteor.subscribe 'get-publication', Session.get 'currentPublicationId', {
onReady: console.log "ready"
onError: (error) -> console.error "error", error
}
Template.publication.publication = ->
# How to know here what was an error thrown in subscription?
JSON.stringify GetPublication.findOne()
我有一个自定义集合:
Meteor.publish 'get-publication', (publicationId) ->
self = this
self.ready()
self.error new Meteor.Error 500, "Test"
我想在模板中输出带有订阅中抛出的内容的消息,而不是(空)发布集合结果。
此外,为什么不调用onReady
和处理程序?onError