zoltan-nz / library-app

Detailed Ember.js v4.7 tutorial for absolute beginners. https://yoember.com

Home Page:http://library-app.firebaseapp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ember.computed.and not right

opened this issue · comments

Thanks for your tutorial ...

In the Contact Page setup homework, I tried to use the Ember.computed.and property
I wrote

  isValid: Ember.computed.match('senderEmailAddress', /^.+@.+\..+$/),
  isNotValid: Ember.computed.not('isValid'),
  isTooShort: Ember.computed.lte('message.length', 4),
 disabled: Ember.computed.and('isNotValid', 'isTooShort'),

so the Send button should be disable when email is invalid and message is too short .. OK
but the when email is valid OR message is long enough the button is Enabled , it should not

I guess we should use Ember.computed.or , Send button will be disabled when one of the 2 computed properties is true ..

disabled: Ember.computed.or('isNotValid', 'isTooShort'),

Isn't it ?

Hi @Erwin16, sorry for the late response. (My notification settings was not properly aligned.)

You are totally right, it is mainly depend how do you manage this boolean logic. For example, I used isMessageEnoughLong which is the opposite of isTooShort. :) So in your case, the or will work properly.