Skip to content

Ember.computed.includes #247

@sandstrom

Description

@sandstrom

The most common long-form computed property in our project are simple checks to see if some array contains a string.

Would you be open to adding this functionality as a computed property?

// wasteful
hasBanana: function() {
  return this.get('possessions').includes('banana');
}.property('possessions', 'banana'),

// wonderful
hasBanana: Ember.computed.includes('possessions', 'banana'),


// usage
let hamster = Hamster.create();

hamster.get('hasBanana'); // false

hamster.set('possessions', ['orange']);
hamster.get('hasBanana'); // false

hamster.set('possessions', ['banana']);
hamster.get('hasBanana'); // true

No RFC yet, just want to get initial reactions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions