kadirahq / flow-router

Carefully Designed Client Side Router for Meteor
MIT License
1.09k stars 194 forks source link

Wrong FlowRouter.getParam values returned #528

Closed krizka closed 8 years ago

krizka commented 8 years ago

Please look at https://github.com/krizka/flow-rerender/tree/master/client To reproduce the strange, please follow:

  1. run meteor
  2. open localhost:3000
  3. open dev console
  4. click 'Foo 1' link, you will see
flow-rerender.js:6 Foo created - onCreated
flow-rerender.js:9 Foo autorun 1 - autorun in onCreated with param 1 called
flow-rerender.js:22 Foo.foo helper Hello - foo helper run here
flow-rerender.js:9 Foo autorun 1 - and autorun again
  1. Click Bar 1 then
flow-rerender.js:29 Bar created - onCreated
flow-rerender.js:32 Bar autorun 1 - autorun with WRONG param 1, returned by FlowRouter.getParam('id')
flow-rerender.js:35 Bar with id 1 not found!!!(anonymous function) @ flow-rerender.js:35(anonymous...
flow-rerender.js:45 Bar.bar helper undefined - if we get the state from id in the url, then we will return wrong data here
flow-rerender.js:32 Bar autorun 2 - and! autorun running again with right ID value

Hope this will help. For further details please ask, or look right to the code, it is pretty simple.

arunoda commented 8 years ago

I don't know what you are trying to achieve here. FlowRouter returns the correct id. See: https://github.com/krizka/flow-rerender/blob/master/client/flow-rerender.js#L10

This is not a FlowRouter issue. I suggest you to ask this on Meteor Forums.

krizka commented 8 years ago

Please, Arunoda. Read my description carefully. Here I created two different Templates which is layouts for the different routes. But uses the same route param called ID. And if you click first link and then second, you will see, that we get wrong ID value from FlowRouter.getParam helper. http://flowrerender.meteor.com/ Or tell me what I'm doing wrong.

paulgrever commented 8 years ago

I am experiencing the same issue. I have a Flowrouter.go and then a publication that depends on params to pull the correct order.

I added a console.log in the publication to show what is happening.

Steps: 1) Click on div that has event listener that utilized Flowrouter.go 2) Have an oncreated function that looks for Flowrouter.getParam('_id')

It runs and throws an error, then reruns with correct OrderId.

 here is pub order null
 Exception from sub advancedFulfillmentOrder id tpuN4DDSSAMS7FZPN Error: Match error: Expected string, got object
     at check (packages/check/match.js:33:1)
     at [object Object].<anonymous> (server/publications/afOrders.js:44:3)
     at packages/matb33_collection-hooks/collection-hooks.js:275:1
     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
     at [object Object]._handler (packages/matb33_collection-hooks/collection-hooks.js:274:1)
     at packages/check/match.js:103:1
     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
     at Object.Match._failIfArgumentsAreNotAllChecked (packages/check/match.js:102:1)
     at maybeAuditArgumentChecks (livedata_server.js:1695:18)
     at [object Object]._.extend._runHandler (livedata_server.js:1023:17)
     at [object Object]._.extend._startSubscription (livedata_server.js:842:9)
     at [object Object]._.extend.protocol_handlers.sub (livedata_server.js:614:12)
     at livedata_server.js:548:43
 Sanitized and reported to the client as: Match failed [400]

 here is pub order sZTFo2sXWJnf9BNFM