colyseus / colyseus-unity-sdk

⚔ Colyseus Multiplayer SDK for Unity
https://docs.colyseus.io/getting-started/unity-sdk/
MIT License
371 stars 102 forks source link

Invert KeyValueEventHandler parameters in MapSchema #141

Open rthery opened 3 years ago

rthery commented 3 years ago
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)