-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Always unblock? #2
Comments
No you are not :) I'm unblocking most of my publications. But some of the initial meteor related publications (like hot code reload related) must run with blocking. What kind of API we are looking for? any ideas? |
Hmm, if reload needs to block, then it might have to wait until MDG improves their pub/sub. I was thinking I could just I feel the same way about Meteor methods. I unblock 90% of them, so shouldn't it really unblock by default and have |
But the real issue is this won't go into core anytime sooner(may be never) how hard we speak :) |
Is the Meteor.publish null, ->
if @userId
Meteor.users.find @userId,
fields:
services: 0
server: 0
else
null |
Hmm. Nope. |
I thought this is the universal subscription that's in every app to get user data? http://support.kadira.io/knowledgebase/articles/379961-what-is-null-autopublish-publication |
Ah! yep. You mean about the core null publication. On Tue, Jul 28, 2015 at 9:53 AM Loren Sands-Ramshaw <
|
for always unblock export default {
safeMethods(methods) {
const _methods = {};
_.each(methods, (method, methodName) => {
_methods[methodName] = function () {
return _isUserLogin(this, arguments, method);
}
});
Meteor.methods(_methods);
},
safePublish(name, func) {
Meteor.publish(name, function () {
this.unblock();
return _isUserLogin(this, arguments, func);
});
},
safePublishComposite(name, func) {
Meteor.publishComposite(name, function () {
this.unblock();
return _isUserLogin(this, arguments, func);
});
},
safePublishTransformed(name, func) {
Meteor.publishTransformed(name, function () {
this.unblock();
return _isUserLogin(this, arguments, func);
});
},
}
function _isUserLogin(ctx, args, fn) {
return ctx.userId
? fn.bind(ctx)(...args)
: ctx.error(new Meteor.Error('unauthorized'));
} |
I'm trying to think of a case when I would not want to unblock my publish function. The only case would be if I'm using the published data to pass as an argument (from the client) to another publish function. However, if I'm doing that, I would always have that code in an autorun, so it will rerun once the data from the first publish function arrives.
So I think it's safe to unblock all functions always, in which case, maybe you could make a version of this package that automatically unblocks all?
Am I overlooking something?
The text was updated successfully, but these errors were encountered: