import { InjectionToken } from '@angular/core';
import {
  Action, 
  createStore,
  Store,
  compose,
  StoreEnhancer
} from 'redux';

import {
  AppState,
  default as reducer
} from './app.reducer';

export const AppStore = new InjectionToken('App.store');

/*
const devtools: StoreEnhancer<AppState> =
 window['devToolsExtension'] ?
  window['devToolsExtension']() : f => f;
*/

export function createAppStore(): Store<AppState> {
  return createStore<AppState, Action<any>, {}, {}>(  // expected 4 got 1
    reducer //,
    //counterReducer,
    //compose(devTools)
  );
}

export const appStoreProviders = [
   { provide: AppStore, useFactory: createAppStore }
];

