private void PrepareContainer(IModule[] platformSpecificModules) { var builder = new ContainerBuilder(); RegisterPlatformSpecificModules(platformSpecificModules, builder); var assembly = Assembly.GetExecutingAssembly(); //redux store var reducer = new ApplicationReducer(); store = new Store <ApplicationState>(reducer); builder.RegisterInstance(store); //register viewmodels builder.RegisterAssemblyTypes(assembly) .Where(t => t.Namespace == "ReduxXamDemo.ViewModels") .AsSelf() .InstancePerDependency(); //navigation navigationService = new NavigationService(store); builder.RegisterInstance(navigationService).As <INavigationService>(); //other services builder.RegisterType <RESTService>().As <IRESTService>().SingleInstance(); Container = builder.Build(); }
public Store() { //listens for incomming actions and then passes it through the reducer to act on the action then updates the state //the state then broadcasts the latest value to it's subscribers Actions.Subscribe(action => _stateSubject.OnNext(ApplicationReducer.Reduce(GetState(), action))); }