[FEATURE conditional-observers-and-listeners]

Specify conditions under which an observer and/or listener should fire. A
condition can be any property that evaluates to a boolean value.

```javascript
App.PersonView = Ember.View.extend({
  friends: [{ name: 'Tom' }, { name: 'Stefan' }, { name: 'Kris' }],

  inDOM: Ember.observer('state', function(obj, keyName) {
    return obj.get(keyName) === 'inDOM';
  }),

  onHover: Ember.on('hover', Ember.when('inDOM', function() {
    // Will only fire if inDOM is true
    // ...
  })),

  valueWillChange: Ember.beforeObserver('content.value', Ember.when('inDOM', function(obj, keyName) {
    // Will only fire if inDOM is true
    this.changingFrom = obj.get(keyName);
  })),

  valueDidChange: Ember.observer('content.value', Ember.when('inDOM', function(obj, keyName) {
    // Will only fire if inDOM is true
    var color = obj.get(keyName) > this.changingFrom ? 'green' : 'red';
    // ...
  }))
});
```

The `when` extension of JavaScript's Function prototype is
available when `Ember.EXTEND_PROTOTYPES` or
`Ember.EXTEND_PROTOTYPES.Function` is true, which is the default.

You can specify conditions that control when an observer and/or listener
should fire. For example:

```javascript
Ember.TextField.extend({

  selectAllTextEnabled: true,

  selectAllText: function() {
    // Executes whenever the "focusIn" event occurs
    // and selectAllTextEnabled is true
    this.$().select();
  }.on('focusIn').when('selectAllTextEnabled')
});