meteor-vue / vue-meteor-tracker

Use Meteor Tracker reactivity inside Vue components
90 stars 20 forks source link

Add official way to override subscribe function #42

Closed akanix42 closed 5 years ago

akanix42 commented 5 years ago

Could you add an official way to override the subscribe function? I'm currently using v1.2.3, and I implement my own override like so:

Vue.config.meteor.subscribe = function (index, publication) {
  if (typeof publication === 'string') {
    return Meteor.subscribe(publication);
  }
  return publication.subscribe();
};

The reason for this is that I use my meteor-publication package, which lets me avoid using magic strings for the publications (I use it in conjunction with TypeScript to enforce the parameter types passed to the publications):

import slideThumbnailPublication from '../publications/slideThumbnail';
  //...
  meteor: {
    $subscribe: {
      subscribedThumbnail() {
        return [slideThumbnailPublication.withData(this.slide._id)];
      },
    },
  //...

If possible, I would like an official way to override the subscribe function so I don't have to worry about it not being possible at all in future versions.

Akryum commented 5 years ago

You can already override the subscribe function with Vue.config.meteor.subscribe. Maybe I misunderstood your question?

akanix42 commented 5 years ago

No, you didn't misunderstand - I somehow missed that this is already documented in the README as the way to override the subscribe function. My apologies!