Пример #1
0
        public void Publish <T>(TKey key, T data)
        {
            List <object> subscriptions;

            if (!_events.TryGetValue(key, out subscriptions))
            {
                _debugger?.LogWarningFormat("No subscriptions found for event type: {0}", typeof(T));
                return;
            }

            _debugger?.LogFormat("Publishing {0}", typeof(T));
            for (int i = subscriptions.Count - 1; i >= 0; i--)
            {
                if (i >= subscriptions.Count)
                {
                    continue;
                }

                var sub = subscriptions[i] as Action <T>;
                sub?.Invoke(data);
            }
        }