Collections in a custom package


#1

Hi,

i want pub/sub in a custom package how can i do this?

server side works fine but on client side i becoming a empty respond.

thanks for help


#2

It’s not different from a non-package approach. Could you post some code?
Just make sure that

  • your collection is defined on the client and the server
  • you’ve added all files to the package in the package.js file
  • you’ve actually included the package

#3

Client side js:

FlowRouter.route('/wiki',{
    action:function(){
        BlazeLayout.render('mainLayout',{main:'categories'});
    }
});

Template.categories.onRendered(function(){
    var self = this;
    self.subscribe('categories');
    console.log(Categories.find().fetch())

});

Collection:

Categories = new Meteor.Collection('categories');

Server Side js:

 Meteor.publish('categories',function(){
    console.log(Categories.find().fetch())
   return Categories.find();
});

packages.js:

Package.describe({
  name: 'test',
  version: '0.0.1',
  // Brief, one-line summary of the package.
  summary: '',
  // URL to the Git repository containing the source code for this package.
  git: '',
  // By default, Meteor will default to using README.md for documentation.
  // To avoid submitting documentation, set this field to null.
  documentation: 'README.md'
});

Package.onUse(function(api) {
    api.versionsFrom('1.1.0.3');

    //client core packages
        api.use(['templating@1.0.0',
                 'minimongo@1.0.0',
                 'livedata@1.0.0'],'client');



    //client packages
        api.use(['semantic:ui-css@2.0.0',
                 'kadira:flow-router',
                 'kadira:blaze-layout'],'client');


    //server packages


    //both packages
        api.use(['mongo@1.0.0',
                 'ddp@1.0.0'],['server','client']);

    //client files
        //layouts
            api.addFiles(['client/layouts/main/main.html'],'client');
        //components
            //categories
                api.addFiles(['client/components/categories/categories.html',
                              'client/components/categories/categories.js'],'client');


    //server files
        //categories
            api.addFiles(['server/categories/publish.js'],'server');


    //both files
        //collections
            api.addFiles(['collections/categories.js'],['server','client'])
});

i think the problem is, i have not the right packages add.


#4

Sorry im so …

I have found the problem.

I have tried in onRendered a log!!

sorry for this