{"action":"created","issue":{"url":"https://api.github.com/repos/peerlibrary/meteor-reactive-publish/issues/24","repository_url":"https://api.github.com/repos/peerlibrary/meteor-reactive-publish","labels_url":"https://api.github.com/repos/peerlibrary/meteor-reactive-publish/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/peerlibrary/meteor-reactive-publish/issues/24/comments","events_url":"https://api.github.com/repos/peerlibrary/meteor-reactive-publish/issues/24/events","html_url":"https://github.com/peerlibrary/meteor-reactive-publish/issues/24","id":192163696,"number":24,"title":"Not working without reloading page","user":{"login":"ajschmaltz","id":1821081,"avatar_url":"https://avatars.githubusercontent.com/u/1821081?v=3","gravatar_id":"","url":"https://api.github.com/users/ajschmaltz","html_url":"https://github.com/ajschmaltz","followers_url":"https://api.github.com/users/ajschmaltz/followers","following_url":"https://api.github.com/users/ajschmaltz/following{/other_user}","gists_url":"https://api.github.com/users/ajschmaltz/gists{/gist_id}","starred_url":"https://api.github.com/users/ajschmaltz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajschmaltz/subscriptions","organizations_url":"https://api.github.com/users/ajschmaltz/orgs","repos_url":"https://api.github.com/users/ajschmaltz/repos","events_url":"https://api.github.com/users/ajschmaltz/events{/privacy}","received_events_url":"https://api.github.com/users/ajschmaltz/received_events","type":"User","site_admin":false},"labels":[{"id":270510346,"url":"https://api.github.com/repos/peerlibrary/meteor-reactive-publish/labels/needs%20feedback","name":"needs feedback","color":"fad8c7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-29T01:26:01Z","updated_at":"2016-11-29T02:20:59Z","closed_at":null,"body":"So, I have a subscription on my client...\r\n\r\n`Meteor.subscribe('posts');`\r\n\r\nand a publish on my server...\r\n\r\n```\r\nMeteor.publish('posts', function () {\r\n    this.autorun(function (computation) {\r\n        var author = Authors.findOne({userId: this.userId});\r\n        return Posts.find({authorId: author._id});\r\n    });\r\n});\r\n```\r\n\r\nBut, it doesn't return any post unless I reload the page in the browser."},"comment":{"url":"https://api.github.com/repos/peerlibrary/meteor-reactive-publish/issues/comments/263457444","html_url":"https://github.com/peerlibrary/meteor-reactive-publish/issues/24#issuecomment-263457444","issue_url":"https://api.github.com/repos/peerlibrary/meteor-reactive-publish/issues/24","id":263457444,"user":{"login":"ajschmaltz","id":1821081,"avatar_url":"https://avatars.githubusercontent.com/u/1821081?v=3","gravatar_id":"","url":"https://api.github.com/users/ajschmaltz","html_url":"https://github.com/ajschmaltz","followers_url":"https://api.github.com/users/ajschmaltz/followers","following_url":"https://api.github.com/users/ajschmaltz/following{/other_user}","gists_url":"https://api.github.com/users/ajschmaltz/gists{/gist_id}","starred_url":"https://api.github.com/users/ajschmaltz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajschmaltz/subscriptions","organizations_url":"https://api.github.com/users/ajschmaltz/orgs","repos_url":"https://api.github.com/users/ajschmaltz/repos","events_url":"https://api.github.com/users/ajschmaltz/events{/privacy}","received_events_url":"https://api.github.com/users/ajschmaltz/received_events","type":"User","site_admin":false},"created_at":"2016-11-29T02:20:59Z","updated_at":"2016-11-29T02:20:59Z","body":"Ok, I created an entire app to reproduce it.  What I found is the behavior only started once I added flow router.  I don't know how to share the code besides posting it here, so I'll do that.\r\n\r\nKeep in mind, this isn't the use case, I'm not using posts and authors, but it best demonstrates.\r\n\r\nFirst, create a meteor app and add these packages:\r\n\r\n- peerlibrary:reactive-publish\r\n- accounts-password\r\n- accounts-ui\r\n- kadira:flow-router\r\n- kadira:blaze-layout\r\n\r\njavascript\r\n'''\r\nvar Posts = new Mongo.Collection('posts');\r\nvar Authors = new Mongo.Collection('authors');\r\nif (Meteor.isServer) {\r\n    Meteor.publish('posts', function () {\r\n        this.autorun(function (computation) {\r\n            var author = Authors.findOne({userId: this.userId});\r\n            console.log(author._id);\r\n            console.log(Posts.find({}).fetch());\r\n            return Posts.find({authorId: author._id});\r\n        });\r\n    });\r\n}\r\nif (Meteor.isClient) {\r\n    FlowRouter.route('/', {\r\n        action: function(params, queryParams) {\r\n            BlazeLayout.render('create');\r\n        }\r\n    });\r\n    FlowRouter.route('/posts', {\r\n        action: function(params, queryParams) {\r\n            BlazeLayout.render('posts');\r\n        }\r\n    });\r\n    Meteor.subscribe('posts');\r\n    Template.create.onCreated(function() {\r\n       this.authorId = new ReactiveVar(null);\r\n    });\r\n    Template.posts.helpers({\r\n       posts: function(){\r\n           return Posts.find({});\r\n       }\r\n    });\r\n    Template.create.helpers({\r\n        authorId: function() {\r\n            return Template.instance().authorId.get();\r\n        }\r\n    })\r\n    Template.create.events({\r\n       'submit #authorForm': function(event, instance) {\r\n           event.preventDefault();\r\n           var author = event.target.author.value;\r\n           instance.authorId.set(Authors.insert({\r\n              userId: Meteor.userId(),\r\n               author: author\r\n           }));\r\n\r\n       },\r\n        'submit #postForm': function(event, instance) {\r\n            event.preventDefault();\r\n            var post = event.target.post.value;\r\n            Posts.insert({\r\n               authorId: instance.authorId.get(),\r\n                post: post\r\n            });\r\n        }\r\n    });\r\n}\r\n```\r\n\r\nand here's the html\r\n\r\n```\r\n<body>\r\n<h2>Follow these steps</h2>\r\n<ul>\r\n    <li>Login</li>\r\n    <li>fill out the first text box and hit enter</li>\r\n    <li>fill out the second text box and hit enter</li>\r\n    <li>click posts</li>\r\n    <li>reload the page</li>\r\n</ul>\r\n</body>\r\n<template name=\"create\">\r\n    {{> loginButtons}}\r\n    {{#if currentUser}}\r\n        <form id=\"authorForm\">\r\n            <input type=\"text\" id=\"author\" name=\"author\" placeholder=\"type anything & enter\"/>\r\n        </form>\r\n        {{#if authorId}}\r\n            <form id=\"postForm\">\r\n                <input type=\"text\" id=\"post\" name=\"post\" placeholder=\"type anything & enter\" />\r\n            </form>\r\n        {{/if}}\r\n    {{/if}}\r\n    <a href=\"/posts\">Posts</a>\r\n</template>\r\n<template name=\"posts\">\r\n    {{#each posts}}\r\n        {{post}}\r\n    {{/each}}\r\n    <a href=\"/\">Create</a>\r\n</template>\r\n```"}}
{"actor":{"display_login":"ajschmaltz"}}