ArraySchema provides incomplete data on change
serjek opened this issue · 3 comments
It seem that ArraySchema provides only diffing value on change:
update 1
{
field : turns,
value : [34],
previousValue : ArraySchema(1) { 34 }
}
update 2
{
field : turns,
value : [33],
previousValue : ArraySchema(2) { 34, 33 }
}
Unfortunately I didn't find the root of the problem yet and switched to MapSchema instead 😅
Hi @serjek, I'm checking this, wouldn't these callbacks help you achieve your goal?
state.array.onAdd +=
state.array.onRemove +=
state.array.onChange +=
Indeed the current value (value
) during the root onChange
callback only has additions in all decoders. It would be more intuitive to have the entire array as current value.
The previousValue
had a bug on colyseus-hx
- it seemed to be a reference to the actual current value, instead of the previous one - which I've fixed here #26
I'm going to update that PR soon fixing the value
as well.
Thanks for clarifications! I guess it's ok to close the ticket once PR is merged.