Example #1
0
        public void Unsubscribe <T>(object tag, OnEvent <T> eventCallback)
        {
            var key = new DictionaryKey(tag, typeof(T));

            if (observerDictionary[key] != null)
            {
                observerDictionary[key].Remove(eventCallback.GetHashCode());
            }
        }
Example #2
0
        public void Dispatch <T>(object tag, T action)
        {
            var key = new DictionaryKey(tag, typeof(T));

            if (observerDictionary.ContainsKey(key))
            {
                foreach (var caller in observerDictionary[key].Values)
                {
                    caller(action);
                }
            }
        }
Example #3
0
        public void Subscribe <T>(object tag, OnEvent <T> eventCallback)
        {
            var key = new DictionaryKey(tag, typeof(T));

            if (!observerDictionary.ContainsKey(key))
            {
                observerDictionary[key] = new Dictionary <int, OnEventWrapper>();
            }

            observerDictionary[key][eventCallback.GetHashCode()] = (object _object) =>
            {
                eventCallback((T)_object);
            };
        }