I wanted to write a simple observer to get callbacks when some of the variables of an object change. It's useful when working with UI for example and this pattern serves me well in my current <[http://www.uwd.pixeye.games/>game](http://www.uwd.pixeye.games/>game) project `( I'm writing game on C# + Unity though )`
The code itself can be found on <[https://gist.github.com/PixeyeHQ/fbec35b25b667b847b4eac413a8539a5>github](https://gist.github.com/PixeyeHQ/fbec35b25b667b847b4eac413a8539a5>github) gist It works : ) BUT 1. I'd like to know if there any more performant / better / idiomatic way to write this in Nim. 2. In C# I had to write tons of custom IEqualityComparer<T> to allow my observer to work with custom types. Do a programmer need to provide any sort of this stuff in Nim? >From what I've seen Nim easily compares tuples variables and anything I drop >on him. In comparing with C# it's insane how less code I wrote in Nim sealed class EqualityVector2 : IEqualityComparer<Vector2> { internal static EqualityVector2 Default = new EqualityVector2(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(Vector2 self, Vector2 vector) { return self.x.Equals(vector.x) && self.y.Equals(vector.y); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int GetHashCode(Vector2 obj) { return obj.x.GetHashCode() ^ obj.y.GetHashCode() << 2; } } Run Thanks in advance!
