UNPKG

@coorpacademy/progression-engine

Version:

32 lines (29 loc) 777 B
// @flow import type { Action, AnswerAction, Config, Content, ExtraLifeAcceptedAction, ExtraLifeRefusedAction } from '../types'; export default function content(config: Config): (Content, Action) => Content { return (c: Content, action: Action): Content => { switch (action.type) { case 'answer': { const answerAction = (action: AnswerAction); return answerAction.payload.content; } case 'extraLifeAccepted': { const acceptAction = (action: ExtraLifeAcceptedAction); return acceptAction.payload.content; } case 'extraLifeRefused': { const refuseAction = (action: ExtraLifeRefusedAction); return refuseAction.payload.content; } default: return c; } }; }