Ejemplo n.º 1
0
 public void Dispatch <T>(IAction action) where T : IState <T>
 {
     if (!subscribers.ContainsKey(action.GetName()))
     {
         return;
     }
     // Before take action
     foreach (Subscriber subscriber in subscribers[action.GetName()])
     {
         subscriber.Invoke(action, true);
     }
     for (int i = 0; i < reducers.Count; i++)
     {
         try
         {
             IReducer <T> reducer = (IReducer <T>)reducers[i];
             this.store[reducer.GetId()] = reducer.Reduce(action, Select <T>(reducer.GetId()));
         }
         catch { }
     }
     // After take action
     foreach (Subscriber subscriber in subscribers[action.GetName()])
     {
         subscriber.Invoke(action, false);
     }
 }