Last active
November 21, 2019 07:53
-
-
Save 2hu12/f3b639dc56f86b48dd19a0ca5bec8616 to your computer and use it in GitHub Desktop.
simple helper vs calss helper reference update which would be fixed by octane
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
arr: [], | |
actions: { | |
emptyArr() { | |
this.set('arr', []); | |
}, | |
nonEmptyArr() { | |
this.set('arr', [1]); | |
}, | |
push(x) { | |
this.arr.pushObject(x); | |
}, | |
pop() { | |
this.arr.popObject(); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*import { helper } from '@ember/component/helper'; | |
import { isEmpty } from '@ember/utils'; | |
export default helper(function emptyHelper([obj]) { | |
console.log('calling empty heler with:', obj); | |
return isEmpty(obj); | |
});*/ | |
import Helper from '@ember/component/helper'; | |
import { computed, get, observer, set } from '@ember/object'; | |
import { equal } from '@ember/object/computed'; | |
export default Helper.extend({ | |
object: [], | |
/*isEmpty: computed('object.length', function () { | |
return get(this, 'object.length') === 0; | |
}).readOnly(),*/ | |
isEmpty: equal('object.length', 0), | |
onChange: observer('object.length', function() { | |
this.recompute(); | |
}), | |
compute([obj]) { | |
set(this, 'object', obj); | |
return get(this, 'isEmpty'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment