Created
October 26, 2016 17:21
-
-
Save code0100fun/b9cde4cdb8f16f84616bc280b146652d to your computer and use it in GitHub Desktop.
boolOr
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'; | |
function boolOr() { | |
var propertyNames = Array.prototype.slice.call(arguments); | |
var computed = Em.computed(function() { | |
var properties = {}; | |
for (var i = 0; i < propertyNames.length; i++) { | |
properties[propertyNames[i]] = Em.get(this, propertyNames[i]); | |
} | |
for (var key in properties) { | |
if (properties.hasOwnProperty(key) && properties[key]) { | |
return true; | |
} | |
} | |
return false; | |
}); | |
return computed.property.apply(computed, propertyNames); | |
} | |
export default Ember.Controller.extend({ | |
starredDate: new Date(), | |
deletedData: new Date(), | |
starredOrDeleted: Ember.computed.or('starredDate', 'deletedData'), | |
isHighlightedOr: Ember.computed.bool('starredOrDeleted'), | |
isHighlightedBoolOr: boolOr('starredDate', 'deletedData'), | |
}); |
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.10.6", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.9.0", | |
"ember-data": "2.9.0", | |
"ember-template-compiler": "2.9.0", | |
"ember-testing": "2.9.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment