dburles / dburles/meteor-collection-helpers
ES6 Getters/Setters support
- Dominant language
- JavaScript
- Stars
- 495
- Forks
- 33
- PR merge metrics
- No merged PRs in 30d
Description
I had to use get/set ES6 syntax in helpers but plugin didn't support those. Here's a patch I suggest to apply in order to support getters/setters in helpers:
```js
_.each(Object.getOwnPropertyDescriptors(helpers), function(descriptor, key) {
Object.defineProperty(self._helpers.prototype, key, descriptor);
});
```
The patch is backward compatible with old good helper methods.
With that change the following helpers start working:
```js
Orders.helpers({
// Still works this way
url() {
return FlowRouter('order', this);
},
// Getters…
get product() {
return Products.findOne(this.productId);
},
get total() {
return this.quantity * this.price;
}
//TODO: Never actually tested Setters yet
});
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.