I’ve been using mdg:validated-method (https://github.com/meteor/validated-method) and really loving it. I like how it forces you into using best-practices. I think we should do the same thing for publications.
- Would define Meteor.validatedPublication
- validate: validate using SimpleSchema
- maxLimit: prevent over-fetching data
- userRequired: calls
this.ready() if user not logged-in
- permissionCheck: calls
this.ready() if returns false
- wrap https://github.com/englue/meteor-publish-composite?
- stretch goals - query builder, REST?
Do you think this package would be useful? Any ideas about how it might work?
Hey, glad you like the package!
There’s one thing I’ve realized when building ValidatedMethod - it’s not really possible to anticipate all of the extensions and wrapper packages up front. For pub/sub, you might want some or all of the following:
- Publish composite
- Reactive publish
- Argument validation
- Subs manager
- Template subscriptions
Basically, I think both Methods and Publications/Subscriptions need some sort of mixin/extension system, much like React components have mixins. That way, you can mix and match the different functionality you need, and it can be published by different people rather than having to be built into the core package itself.
Also, I wouldn’t attach it to
Meteor.validatedPublication - probably a top-level symbol, or in 1.3 it would just be a module -
import ValidatedPublication from 'validated-publication'.
This idea just came to my head! Did you make any progress with it?
Since the last post, I added a mixin system for ValidatedMethod and it seems to be working well!