import * as actions from "@nteract/actions" ; import { makeTransformsRecord } from "@nteract/types" ; import { List , Map } from "immutable" ; import { Action , Reducer } from "redux" ; import { combineReducers } from "redux-immutable" ; import * as React from "react" ; export const byId = ( state = Map < string , React . ComponentClass > ( ) , action ) : Map < string , React . ComponentClass > => { let typedAction ; switch ( action . type ) { case actions . ADD_TRANSFORM : typedAction = action as actions . AddTransform ; return state . set ( typedAction . payload . mediaType , typedAction . payload . component ) ; case actions . REMOVE_TRANSFORM : typedAction = action as actions . RemoveTransform ; return state . delete ( typedAction . payload . mediaType ) ; default : return state ; } } ; export const displayOrder = ( state = List ( ) as List < string > , action ) : List < string > => { let typedAction ; switch ( action . type ) { case actions . ADD_TRANSFORM : typedAction = action as actions . AddTransform ; return state . insert ( 0 , typedAction . payload . mediaType ) ; case actions . REMOVE_TRANSFORM : typedAction = action as actions . RemoveTransform ; return state . delete ( state . indexOf ( typedAction . payload . mediaType ) ) ; default : return state ; } } ; export const transforms = combineReducers ( { byId , displayOrder } , makeTransformsRecord as any ) ;