mgschoen / prosecco-js

Super light and fizzy data binding
0 stars 0 forks source link

Array watchers fire twice for primitive manipulations #3

Closed mgschoen closed 5 years ago

mgschoen commented 5 years ago

Suppose you have an array in your model and watch it:

var app = new Prosecco(document.getElementById('app-root'), {
    list: [ 'a', 'b', 'c' ]
})

app.watch('list', function (oldList, newList) {
    alert('Changed from "' + oldList + '" to "' + newList + '"')
})

Manipulating a single value in that array makes the watcher function fire twice. E.g.:

app.model.list.push('f')

Should fire only once

mgschoen commented 5 years ago

Solved in https://github.com/mgschoen/prosecco-js/commit/de16c67f7497543afcf85de85d0e823d2ec0e8d2