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