public IDisposable ProcessEntity <T>(IReactToDataSystem <T> system, IEntity entity) { var hasEntityPredicate = system.TargetGroup is IHasPredicate; var reactObservable = system.ReactToData(entity); if (!hasEntityPredicate) { return(reactObservable.Subscribe(x => system.Execute(entity, x))); } var groupPredicate = system.TargetGroup as IHasPredicate; return(reactObservable .Where(x => groupPredicate.CanProcessEntity(entity)) .Subscribe(x => system.Execute(entity, x))); }
public SubscriptionToken ProcessEntity <T>(IReactToDataSystem <T> system, IEntity entity) { var hasEntityPredicate = system.TargetGroup.TargettedEntities != null; var subscription = system.ReactToEntity(entity) .Subscribe(x => { if (hasEntityPredicate) { if (system.TargetGroup.TargettedEntities(entity)) { system.Execute(entity, x); } return; } system.Execute(entity, x); }); return(new SubscriptionToken(entity, subscription)); }
public IDisposable ProcessEntity <T>(IReactToDataSystem <T> system, IEntity entity) { var hasEntityPredicate = system.Group is IHasPredicate; var reactObservable = system.ReactToData(entity); if (false == hasEntityPredicate) { return(reactObservable.Subscribe(x => system.Process(entity, x))); } var groupPredicate = (IHasPredicate)system.Group; return(reactObservable.Subscribe(x => { if (groupPredicate.CanProcessEntity(entity)) { system.Process(entity, x); } })); }
public SubscriptionToken ProcessEntity <T>(IReactToDataSystem <T> system, IEntity entity) { var hasEntityPredicate = system.TargetGroup is IHasPredicate; var subscription = system.ReactToData(entity) .Subscribe(x => { if (hasEntityPredicate) { var groupPredicate = system.TargetGroup as IHasPredicate; if (groupPredicate.CanProcessEntity(entity)) { system.Execute(entity, x); } return; } system.Execute(entity, x); }); return(new SubscriptionToken(entity, subscription)); }
public IEnumerable <SubscriptionToken> Setup <T>(IReactToDataSystem <T> system) { var groupAccessor = PoolManager.CreateGroupAccessor(system.TargetGroup); return(groupAccessor.Entities.ForEachRun(x => ProcessEntity(system, x))); }