mennovanslooten / underscore-observe

This is an extension to Underscore that allows you to add observer functions to any standard JavaScript Array.
http://mennovanslooten.github.com/underscore-observe
MIT License
59 stars 16 forks source link

Direct assignment is ignored when followed by creating a new observer #8

Closed mennovanslooten closed 9 years ago

mennovanslooten commented 9 years ago
var a = ['bar'];

_.observe(a, 'update', function(new_item, old_item, item_index) {
    console.log(new_item + ' was changed from ' + old_item + ' at ' + item_index);
});

// should log "foo was changed from bar at 0"
a[0] = 'foo';

// Prevents 'foo' from being picked up
_.observe(a, 'delete', function() { });