コード例 #1
0
ファイル: SignalBus.cs プロジェクト: GAIA-project/AR
        void SubscribeInternal(SignalSubscriptionId id, Action <object> callback)
        {
            Assert.That(!_subscriptionMap.ContainsKey(id),
                        "Tried subscribing to the same signal with the same callback on Zenject.SignalBus");

            var declaration  = GetDeclaration(id.SignalType);
            var subscription = SignalSubscription.Pool.Spawn(callback, declaration);

            _subscriptionMap.Add(id, subscription);
        }
コード例 #2
0
ファイル: SignalBus.cs プロジェクト: pavel-fadrhonc/of2
        void SubscribeInternal(SignalSubscriptionId id, Action <object> callback)
        {
            Assert.That(!_subscriptionMap.ContainsKey(id),
                        "Tried subscribing to the same signal with the same callback on Zenject.SignalBus");

            var declaration = GetDeclaration(id.SignalId);

            if (declaration == null)
            {
                throw Assert.CreateException("Tried subscribing to undeclared signal '{0}'!", id.SignalId);
            }

            var subscription = _subscriptionPool.Spawn(callback, declaration);

            _subscriptionMap.Add(id, subscription);
        }
コード例 #3
0
ファイル: SignalBus.cs プロジェクト: GAIA-project/AR
        void UnsubscribeInternal(SignalSubscriptionId id, bool throwIfMissing)
        {
            SignalSubscription subscription;

            if (_subscriptionMap.TryGetValue(id, out subscription))
            {
                _subscriptionMap.RemoveWithConfirm(id);
                subscription.Dispose();
            }
            else
            {
                if (throwIfMissing)
                {
                    throw Assert.CreateException(
                              "Called unsubscribe for signal '{0}' but could not find corresponding subscribe.  If this is intentional, call TryUnsubscribe instead.");
                }
            }
        }