2015-02-12 67 views
2

有沒有辦法禁用流星自動發佈警告?流星 - 禁用自動發佈警告

我剛剛進入流星又一段時間,所以我還在學習。我設置了一個發佈(),因爲我需要它在Iron Router中的onWait。然而這引發了Meteor的一個大警告:

** You've set up some data subscriptions with Meteor.publish(), but 
** you still have autopublish turned on. Because autopublish is still 
** on, your Meteor.publish() calls won't have much effect. All data 
** will still be sent to all clients. 
** 
** Turn off autopublish by removing the autopublish package: 
** 
** $ meteor remove autopublish 
** 
** .. and make sure you have Meteor.publish() and Meteor.subscribe() calls 
** for each collection that you want clients to see. 

這實際上是很好的信息...第一次它告訴我。但是,隨着我轉型,學習和試驗,我不一定要刪除自動發佈。

每次我進行更改並重新啓動服務器時,都會收到此消息,這使得很難發現何時拋出異常或什麼時候發生異常。

如果有一個開關可以設置,表示我不希望顯示警告,那該多好。在那兒?

回答

3

如果你看看livedata_server.js的來源,你會發現publish實際上有三個參數 - 最後一個是options。您可以使用optionsis_auto屬性誘騙publish認爲您的功能是autopublish機制的一部分,這會使其避免打印錯誤。例如:

Meteor.publish('messages', 
    function() { 
    return Messages.find(); 
    }, 
    {is_auto: true} 
); 

請注意,您需要將此黑客應用到您的每個發佈商以避免看到警告。

+0

謝謝。我會繼續接受這個。無論如何,我最終還是刪除了自動發佈,但是爲了將來的參考,這可能是我在處於項目初始階段的時候要走的路。 – samanime 2015-02-12 05:04:13