colyseus-unity-sdk icon indicating copy to clipboard operation
colyseus-unity-sdk copied to clipboard

Invert KeyValueEventHandler parameters in MapSchema

Open rthery opened this issue 3 years ago • 0 comments

public event KeyValueEventHandler<T, string> OnAdd;
public event KeyValueEventHandler<T, string> OnChange;
public event KeyValueEventHandler<T, string> OnRemove;

MapSchema uses string then T everwhere except for these events. Because of this inversion, it means we can't just directly call handlers for these events with other MapSchema methods, like ForEach, so you end up having to write mapSchemaInstance.Foreach((key, t) => OnAdd(t, key)) instead of a nicer mapSchemaInstance.Foreach(OnAdd)

I know it's a breaking chance, but it would just be more coherent and help with readability (I haven't checked other collections, may need to update them as well)

rthery avatar Apr 10 '21 15:04 rthery