0
我打電話更新Meteor.users客戶端更新配置文件,我發現它更新後點擊路由器。我知道Meteor.user()是被動的,因爲我正在更新它,Meteor會相應地更新。但我想我不確定它爲什麼會觸及路由器,特別是當我沒有在該頁面上獲取任何用戶數據時。這裏是我的更新:流星用戶更新呼叫路由器
Meteor.users.update(Meteor.userId(), {$addToSet: {'profile.collection': @id}})
完全航線代碼
Meteor.startup ->
Session.setDefault 'subpage', ''
Router.configure
layoutTemplate: "layout"
loadingTemplate: "loading"
Router.before ->
routeName = @route.name
if Meteor.user() or Meteor.loggingIn()
if _.include(["index"], routeName) then Router.go('collection')
Session.set 'currentPage', routeName
else
if routeName isnt 'index' then Router.go 'index'
Router.map ->
@route "index",
path: "/"
@route "collection"
@route "discover"
@route "playlists"
@route "playlist",
path: "/playlists/:_id"
data: ->
# Playlists.findOne(@params._id)
如果您使用鐵路路由器,一些掛鉤是被動的。請添加路線代碼以獲得更完整的答案。 –
僅僅因爲我在before hook中調用Meteor.user()? – ZDixon