adopted-ember-addons / ember-paper

The Ember approach to Material Design.
https://ember-paper.netlify.app/
MIT License
888 stars 333 forks source link

remove unnecesary "fn" helper #1121

Closed betocantu93 closed 4 years ago

betocantu93 commented 4 years ago

The new changes to paper-menu paper-select paper-chips and paper-autocomplete had unnecessary usage of fn helper, the recommended way in octane is just

import { action } from '@ember/object';
export default class SomeComponent extends Component {

  @action
  open() {
    //do stuff that needs this component's context
   this.set('isOpen', true);
  }

 calculatePosition(e) {
    //this function doesn't need component's context
    e.getBoundingClientRect(); 
  }

 @action
  async close(opt) {
   //This function needs component's context and receives an argument

    if(opt.id === this.selectedOpt.id) { //whatever
      return await this.onClose();
    }
  }
}

<button {{on "click" this.open}}>Open Stuff </button>

{{#if this.isOpen}}
   <div {{did-insert this.calculatePosition}} ...attributes>
     <button {{on "click" (fn this.close @opt)}}>Close</button>
   </div>
{{/if}}
miguelcobain commented 4 years ago

Thank you. This makes sense to me now. 👍