import { TCreatorArgs, ICreator } from "./types"; import { TCreationType } from "../commands/types"; import { HelperFunctionCreator, ReactComponentCreator, ReduxSagaCreator, GlobalActionCreator, GlobalReduxReducerCreator } from "./creators"; interface ICreatorsFactory { build: () => ICreator | void; } class CreatorsFactory implements ICreatorsFactory { constructor(private type: TCreationType, private config: TCreatorArgs) {} build() { const { type, config } = this; switch (type) { case "helper-class": return new HelperFunctionCreator(config); case "react-component": return new ReactComponentCreator(config); case "redux-saga": return new ReduxSagaCreator(config); case "global-action-creator": return new GlobalActionCreator(config); case 'global-redux-reducer': return new GlobalReduxReducerCreator(config); } } } export { CreatorsFactory };