Skip to content
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

Ecmascript problem #78

Open
mervynteo opened this issue May 4, 2017 · 3 comments
Open

Ecmascript problem #78

mervynteo opened this issue May 4, 2017 · 3 comments

Comments

@mervynteo
Copy link

mervynteo commented May 4, 2017

I used a global helper below. However after I changed to ES6 or 2015 format, it broke.

Original

Channels.helpers({
   oppParty: function (){ 
      if( this.originator === Meteor.userId() ) {
         return Meteor.users.findOne({ _id: this.recipient });
      } else {
         return Meteor.users.findOne({ _id: this.originator });
      }
   }
});

changed to

Channels.helpers({
   oppParty (){ return this.originator === Meteor.userId() ? this.recipient : this.originator; }
});

I tried various combination and installed, uninstalled ES6, nothing worked. Anyone has the same issue?

@dburles
Copy link
Owner

dburles commented May 4, 2017

Using object method shorthand is okay however don't use arrow functions as then this won't be bound to the correct context. Could you post a more complete code example?

@mervynteo
Copy link
Author

@dburles updated as above. Thanks!

@dburles
Copy link
Owner

dburles commented May 4, 2017

Looks fine to me (see the examples in the readme).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants