Meteor 1.3 (es6): Publications and subscriptions

Hello,
I’m trying to use the following repo https://github.com/PeterChauYeg/meteor-react-base that uses ecmascript 6 to kickstart a small project. However I’m having trouble using collections (given that documentation on Meteor 1.3 with es6 is still rather scarce).

When exporting a collection from my lib/collection.js file and then importing it in a server/server.js file, I can insert in and then publish said description, however I’m having trouble subscribing to it in a client file (jsx or otherwise)

Here is my code:

lib/collections.js

const Test = new Mongo.Collection(“test”);
export default Test;

server/server.js

import Test from ‘/lib/collections.js’;
Test.insert({name: “Song”, createdAt: new Date()});
Test.insert({name: “Sing”, createdAt: new Date()});
Test.insert({name: “Sang”, createdAt: new Date()});
const machin = Meteor.publish(“test”, function(){
Test.find();
});

client/client.js

const handle = Meteor.subscribe(“test”);
console.log(handle); //The handle is displayed correctly

if(handle.ready()){
console.log(Test.findOne()); // Test Reference is not defined
}

I’m a beginner in both Javascript and Meteor, so if you could please explain to me what causes this behaviour and how to fix it, I would be grateful.
Also, any and all documentation pertaining to using Meteor with es6 syntax would be most welcome.

Thank you.

You need to return something from your publication so it should be:

const machin = Meteor.publish("test", function(){
  return Test.find(); 
});

Can it be that you need to import Test from '/lib/collections.js' in your client.js?

I just announced my Meteor-React-start-app which has publication and subscription working