openlayers/ol3 — pull request #1349 by tschaub (2013-12-11 08:48:57+00:00)
Title: Clean up layer change event handling

Currently, layers [listen for some specific property changes](https://github.com/openlayers/ol3/blob/d53ad07279bb02a2904e5e29ad7c46175817f160/src/ol/layer/layerbase.js#L75-L84) and [dispatch a generic change event](https://github.com/openlayers/ol3/blob/d53ad07279bb02a2904e5e29ad7c46175817f160/src/ol/layer/layerbase.js#L257-L261). Since `ol.Object` already dispatches an event with the same type (`'change'`), this results in two change events for every change in value for this set of properties (brightness, contrast, hue, opacity, saturation, min res, max res). The redundant event is only fired if the source is visible and ready. Presumably, the intention was to have no change event fired if the layer was not visible or ready.

The result is that you get two complete re-renderings of the map for some layer property changes. See the example below (using the simple.html example).

```js
var layer = map.getLayers().getAt(0)
layer.on('change', function() {console.log('change', arguments)})
map.on('postrender', function() {console.log('postrender')})

layer.set('opacity', 0.5)
// change [goog.events.Event]
// postrender
// change [goog.events.Event]
// postrender

layer.setOpacity(1)
// postrender
// change [goog.events.Event]
// postrender
// change [goog.events.Event]
```

We also get a complete map re-rendering for irrelevant layer property changes (e.g. `layer.set('foo', 'bar')`). But that could be addressed separately.