Closed chrisbutler closed 10 years ago
however
<script type="text/javascript">
__fast_render_config = {"subscriptions":{},"serverRoutePath":"/","subscriptionIdMap":{},"loadedSubscriptions":{}}
</script>
and
<script type="text/javascript">
if(typeof __init_fast_render == 'function') {
__init_fast_render("%7B%22collectionData%22:%7B%7D%7D")
}
</script>
Same for me!
Are you guys with Meteor 0.8 with Iron Router? If possible send a me a sample version of your routes where I can work on?
i'm on 0.7.0.1 with IR 0.6.4, and my routes are generally all using controllers like this:
PublisherController = FastRender.RouteController.extend({
waitOn: function () {
return [
this.subscribe('polls'),
this.subscribe('authors')
];
}
});
changing this.subscribe
to Meteor.subscribe
seems to work
yep. You've to use Meteor.subscribe.
Is your problem got solved?
yeah that issue is solved. i'm also getting error: ReferenceError: Session is not defined
which i wasn't seeing before, but guarding with if (typeof Session !== 'undefined')
is working there
or you can use Meteor.isClient
too.
For me its not solved yet ;-)
I am on Meteor 0.8.0 and iron-router 0.7.0 Fast Render is at the latest 0.1.23 version
One of my route controllers (all are pretty similar):
@DashboardController = FastRender.RouteController.extend
template: 'projects_list'
yieldTemplates:
dashboard_header: to: 'header'
dashboard_footer: to: 'footer'
waitOn: -> Meteor.subscribe 'projects'
onBeforeAction: -> if Meteor.isClient and Meteor.user() == null then @redirect Router.ROUTES.LOGIN
@arunoda good point, thanks!
@DominikGuzei shall we make this into a new issue.
Please give me following.
FastRender.Log.enable()
on the browser console and send me the logsActually there is no error, everything works – but Fast Render doesn't send initial data when the page is first loaded.
My Scenario:
A user is logged in and has 1-X projects He is sent to the dashboard route where all projects are listed:
@DashboardController = FastRender.RouteController.extend
template: 'projects_list'
yieldTemplates:
dashboard_header: to: 'header'
dashboard_footer: to: 'footer'
waitOn: -> Meteor.subscribe 'projects'
onBeforeAction: -> if Meteor.isClient and Meteor.user() == null then @redirect Router.ROUTES.LOGIN
It works, the projects get loaded – but over DDP (like normal) This is what gets embedded into the document by fast-render:
if(typeof __init_fast_render == 'function') {
__init_fast_render("%7B%22collectionData%22:%7B%7D%7D")
}
This are the logs I get from fast-render:
DDP_SEND:
Object
id: "yS7vEfSCEpzmPP7zb"
msg: "sub"
name: "meteor.loginServiceConfiguration"
params: Array[0]
__proto__: Object
log.js:7
DDP_SEND:
Object
id: "1"
method: "login"
msg: "method"
params: Array[1]
__proto__: Object
log.js:7
DDP_SEND:
Object
id: "nHtsG6eQyji6idupJ"
msg: "sub"
name: "projects"
params: Array[0]
__proto__: Object
log.js:7
DDP_SEND:
Object
msg: "connect"
support: Array[1]
version: "pre1"
__proto__: Object
log.js:7
DDP_SEND:
Object
id: "1"
method: "login"
msg: "method"
params: Array[1]
__proto__: Object
log.js:7
DDP_SEND:
Object
id: "KaLSFmhAsCN2nnRqF"
msg: "sub"
name: "meteor_autoupdate_clientVersions"
params: Array[0]
__proto__: Object
log.js:7
DDP_SEND:
Object
id: "yS7vEfSCEpzmPP7zb"
msg: "sub"
name: "meteor.loginServiceConfiguration"
params: Array[0]
__proto__: Object
log.js:7
DDP_SEND:
Object
id: "nHtsG6eQyji6idupJ"
msg: "sub"
name: "projects"
params: Array[0]
__proto__: Object
log.js:7
DDP_RECIEVE:
Object
collection: "users"
fields: Object
id: "zTBnJnGKZ8Zw8wsE3"
msg: "added"
__proto__: Object
log.js:7
REVERTING_BACK_TO_ORIGINAL_DDP_HANDLING: log.js:7
DDP_RECIEVE:
Object
methods: Array[1]
msg: "updated"
__proto__: Object
log.js:7
DDP_RECIEVE:
Object
collection: "meteor_autoupdate_clientVersions"
fields: Object
id: "8df4c02a6aec80ec13bfbd70a805b6686900cdfd"
msg: "added"
__proto__: Object
log.js:7
DDP_RECIEVE:
Object
msg: "ready"
subs: Array[1]
__proto__: Object
log.js:7
DDP_RECIEVE:
Object
msg: "ready"
subs: Array[1]
__proto__: Object
log.js:7
DDP_RECIEVE:
Object
collection: "projects"
fields: Object
id: "HTavSiDGuAcy5Px94"
msg: "added"
__proto__: Object
log.js:7
DDP_RECIEVE:
Object
msg: "ready"
subs: Array[1]
__proto__: Object
log.js:7
Does you routes can be available on the Server Side?
I think they are available on both sides. I put them in a top-level folder named shared
I really can't say much with this info. Can you please create a re-produceable minimal repo. Then I can look it here.
hmm.. ok it could be that they are not run on the server side – I just tried to console log if Meteor.isServer and nothing happens .. I have to look into that
ah okay.
ok the file is definitely served on the server side too. But waitOn
or onBeforeAction
are never called on server. Is this expected behaviour?
waitOn
needs to get called, others are not.
Ok, mine never got called!
I changed the router to explicit controller
params, and it gets called now:
Router.map ->
@route Router.ROUTES.DASHBOARD, path: '/', controller: DashboardController
The static fast-render output changed to this:
if(typeof __init_fast_render == 'function') {
__init_fast_render("%7B%22collectionData%22:%7B%22projects%22:%5B%5B%5D%5D%7D%7D")
}
And the fast-render logs changed to this:
DDP_SEND:
Object {msg: "sub", id: "ZRX79ERbD4Cd5QmaJ", name: "meteor.loginServiceConfiguration", params: Array[0]}
log.js:7
DDP_SEND:
Object {msg: "method", method: "login", params: Array[1], id: "1"}
log.js:7
DDP_SEND:
Object {msg: "sub", id: "NDENu4H9NCBoCfdd9", name: "projects", params: Array[0]}
log.js:7
FAKE_SUB_READY: projects log.js:7
DDP_RECIEVE:
Object {msg: "ready", subs: Array[1], frGen: true}
log.js:7
DDP_SEND:
Object {msg: "connect", version: "pre1", support: Array[1]}
log.js:7
DDP_SEND:
Object {msg: "method", method: "login", params: Array[1], id: "1"}
log.js:7
DDP_SEND:
Object {msg: "sub", id: "5aSSXL9CLs6bdnLqT", name: "meteor_autoupdate_clientVersions", params: Array[0]}
log.js:7
DDP_SEND:
Object {msg: "sub", id: "ZRX79ERbD4Cd5QmaJ", name: "meteor.loginServiceConfiguration", params: Array[0]}
log.js:7
DDP_SEND:
Object {msg: "sub", id: "NDENu4H9NCBoCfdd9", name: "projects", params: Array[0]}
log.js:7
FAKE_SUB_READY: projects log.js:7
DDP_RECIEVE:
Object {msg: "ready", subs: Array[1], frGen: true}
log.js:7
DDP_RECIEVE:
Object {msg: "added", collection: "users", id: "zTBnJnGKZ8Zw8wsE3", fields: Object}
log.js:7
DDP_RECIEVE:
Object {msg: "updated", methods: Array[1]}
log.js:7
DDP_RECIEVE:
Object {msg: "added", collection: "meteor_autoupdate_clientVersions", id: "14ff8b135ac283081a6593a22f5e36979c8fe936", fields: Object}
log.js:7
DDP_RECIEVE:
Object {msg: "ready", subs: Array[1]}
log.js:7
DDP_RECIEVE:
Object {msg: "ready", subs: Array[1]}
log.js:7
DDP_RECIEVE:
Object {msg: "added", collection: "projects", id: "HTavSiDGuAcy5Px94", fields: Object}
log.js:7
DDP_RECIEVE:
Object {msg: "ready", subs: Array[1]}
log.js:7
DELETING_SUBSCRIPTION: projects NDENu4H9NCBoCfdd9 log.js:7
REVERTING_BACK_TO_ORIGINAL_DDP_HANDLING:
However if I run it with DDP_DEFAULT_CONNECTION_URL=http://localhost:3030 meteor
it still doesn't work:
GET http://localhost:3030/sockjs/info?cb=tavzyvwwsw net::ERR_CONNECTION_REFUSED sockjs-0.3.4.js:854
DDP_SEND:
Object {msg: "sub", id: "3wEmwcH2bkH9YFXWv", name: "meteor.loginServiceConfiguration", params: Array[0]}
log.js:7
DDP_SEND:
Object {msg: "method", method: "login", params: Array[1], id: "1"}
log.js:7
DDP_SEND:
Object {msg: "sub", id: "HR8heAYTioXDrryfT", name: "projects", params: Array[0]}
log.js:7
FAKE_SUB_READY: projects log.js:7
DDP_RECIEVE:
Object {msg: "ready", subs: Array[1], frGen: true}
log.js:7
GET http://localhost:3030/sockjs/info?cb=9r8fmiwxv5 net::ERR_CONNECTION_REFUSED sockjs-0.3.4.js:854
GET http://localhost:3030/sockjs/info?cb=z89c7mp_m5 net::ERR_CONNECTION_REFUSED sockjs-0.3.4.js:854
But no projects are shown …
Ok I noticed that within my publish function this.userId
is at first undefined
(when hit by fast-render) and then zTBnJnGKZ8Zw8wsE3
when hit by "normal" DDP request. This is a problem because I filter my projects like this:
Meteor.publish 'projects', ->
ProjectsCollection = Injector.get('Collections').get('projects')
console.log this.userId
ProjectsCollection.find { owner_id: this.userId }, sort: created_at: 1
So fast-render will not get any projects, but normal request do! Is there something I am missing in my setup?
Okay. there might be issue with 0.8 and how FR does auth. I'll double check.
Thanks for the fast response! That's amazing support of you :+1:
I have put together a simple example application that shows this problem: https://github.com/CodeAdventure/meteor-fast-render-userid-failure
Hope this helps you with debugging the problem!
I fixed this and made a commit to the master. give it a try
Thank you very much Arunoda! It works as expected now :-) :+1:
Awesome.
Arunoda Susiripala
@arunoda http://twitter.com/arunoda http://gplus.to/arunodahttps://github.com/arunoda http://www.linkedin.com/in/arunoda
On Fri, Apr 4, 2014 at 2:55 PM, Dominik Guzei notifications@github.comwrote:
Thank you very much Arunoda! It works as expected now :-) [image: :+1:]
— Reply to this email directly or view it on GitHubhttps://github.com/arunoda/meteor-fast-render/issues/38#issuecomment-39546453 .