Exemplo n.º 1
0
        public SubscriptionToken ProcessEntity(IEntityReactionSystem system, IEntity entity)
        {
            var observable = system.Impact(entity);

            var subscription = observable?.Subscribe(x => system.Reaction(entity)) ?? Disposable.Empty;

            return(new SubscriptionToken(entity, subscription));
        }
        public SubscriptionToken ProcessEntity(IEntityReactionSystem system, IEntity entity)
        {
            var hasEntityPredicate = system.TargetGroup is IHasPredicate;
            var subscription       = system.Impact(entity)
                                     .Subscribe(x =>
            {
                if (hasEntityPredicate)
                {
                    var groupPredicate = system.TargetGroup as IHasPredicate;
                    if (groupPredicate.CanProcessEntity(x))
                    {
                        system.Reaction(x);
                    }
                    return;
                }

                system.Reaction(x);
            });

            return(new SubscriptionToken(entity, subscription));
        }