Skip to content

Commit

Permalink
trigger delete callbacks when collection is replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Aug 19, 2020
1 parent 7bdad84 commit b87ba50
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions Assets/Plugins/Colyseus/Serializer/Schema/Schema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,25 +402,21 @@ public void Decode(byte[] bytes, Iterator it = null, ReferenceTracker refs = nul
{
refs.Remove(((IRef)previousValue).__refId);

////
//// TODO: Trigger onRemove if structure has been replaced.
////
//const deletes: DataChange[] = [];
//const entries: IterableIterator <[any, any] > = previousValue.entries();
//let iter: IteratorResult <[any, any] >;
//while ((iter = entries.next()) && !iter.done)
//{
// const [key, value] = iter.value;
// deletes.push({
// op: OPERATION.DELETE,
// field: key,
// // dynamicIndex,
// value: undefined,
// previousValue: value,
// });
//}

//allChanges.set(previousValue['$changes'].refId, deletes);
var deletes = new List<DataChange>();
var items = ((ISchemaCollection)previousValue).GetItems();

foreach (var key in items.Keys)
{
deletes.Add(new DataChange()
{
DynamicIndex = key,
Op = (byte)OPERATION.DELETE,
Value = null,
PreviousValue = items[key]
});
}

allChanges[(object)((IRef)previousValue).__refId] = deletes;
}
}

Expand Down

0 comments on commit b87ba50

Please sign in to comment.