import { Injectable } from '@angular/core' ; import { Action } from '@ngrx/store' ; import { ActionWithPayload } from './action-with-payload' ; import { Observable } from 'rxjs' ; import { User , Game , Question } from '../../../shared/model' ; @ Injectable ( ) export class GameActions { static GET_ACTIVE_GAMES = 'GET_ACTIVE_GAMES' ; getActiveGames ( user ) { return { type : GameActions . GET_ACTIVE_GAMES , payload : user } ; } static GET_ACTIVE_GAMES_SUCCESS = 'GET_ACTIVE_GAMES_SUCCESS' ; getActiveGamesSuccess ( games ) { return { type : GameActions . GET_ACTIVE_GAMES_SUCCESS , payload : games } ; } static CREATE_NEW_SUCCESS = 'CREATE_NEW_SUCCESS' ; createNewGameSuccess ( gameId ) { return { type : GameActions . CREATE_NEW_SUCCESS , payload : gameId } ; } static RESET_NEW = 'RESET_NEW' ; resetNewGame ( ) { return { type : GameActions . RESET_NEW , payload : null } ; } static CREATE_NEW_GAME_ERROR = 'CREATE_NEW_GAME_ERROR' ; createNewGameError ( error ) { return { type : GameActions . CREATE_NEW_GAME_ERROR , payload : error } ; } static GET_USER_REACTION = '[GamePlay] GetUserReaction' ; GetUserReaction ( payload ) { return { type : GameActions . GET_USER_REACTION , payload : payload } ; } static GET_USER_REACTION_SUCCESS = '[GamePlay] GetUserReactionSuccess' ; GetUserReactionSuccess ( status ) { return { type : GameActions . GET_USER_REACTION_SUCCESS , payload : status } ; } static GET_QUESTION_SUCCESS = '[GamePlay] GetQuestionSuccess' ; GetQuestionSuccess ( question ) { return { type : GameActions . GET_QUESTION_SUCCESS , payload : question } ; } static GET_QUESTION = '[GamePlay] GetQuestion' ; GetQuestion ( questionId ) { return { type : GameActions . GET_QUESTION , payload : questionId } ; } static UPDATE_QUESTION_STAT = '[GamePlay] UpdateQuestionStat' ; UpdateQuestionStat ( questionId , type ) { return { type : GameActions . UPDATE_QUESTION_STAT , payload : { questionId : questionId , type : type } } ; } static UPDATE_QUESTION_STAT_SUCCESS = '[GamePlay] UpdateQuestionStatSuccess' ; UpdateQuestionStatSuccess ( ) { return { type : GameActions . UPDATE_QUESTION_STAT_SUCCESS , payload : null } ; } static USER_REACTION = '[GamePlay] UserReaction' ; UserReaction ( payload ) { return { type : GameActions . USER_REACTION , payload : payload } ; } static UPADTE_USER_REACTION_SUCCESS = '[GamePlay] UpdateUserReactionSuccess' ; UpdateUserReactionSuccess ( ) { return { type : GameActions . UPADTE_USER_REACTION_SUCCESS , payload : null } ; } }