This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ActionReducerMap, createSelector, MetaReducer } from "@ngrx/store"; | |
import { environment } from "../../environments/environment"; | |
import { heroReducer, HeroState } from "./hero.reducer"; | |
import { villainReducer, VillainState } from "./villain.reducer"; | |
export interface State { | |
heroes: HeroState; | |
villains: VillainState; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from "@angular/core"; | |
import { Actions, Effect, ofType } from "@ngrx/effects"; | |
import { HeroService } from "../heroes/hero.service"; | |
import { Observable, of } from "rxjs"; | |
import { Action } from "@ngrx/store"; | |
import * as heroActions from "../actions/hero.actions"; | |
import { | |
catchError, | |
exhaustMap, | |
map, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { HeroActions, HeroActionTypes } from "../actions/hero.actions"; | |
import { Hero } from "../models/hero.model"; | |
export interface HeroState { | |
heroes: Hero[]; | |
hero: Hero; | |
requesting: boolean; | |
error: string; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Action } from "@ngrx/store"; | |
import { Hero } from "../models/hero.model"; | |
/* | |
* Action Types | |
*/ | |
export enum HeroActionTypes { | |
LoadHeroes = "[Hero] Load Heroes", | |
LoadHeroesSuccess = "[Hero] Load Heroes Success", | |
LoadHeroesFail = "[Hero] Load Heroes Fail", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import ReactDOM from "react-dom"; | |
import "./index.css"; | |
import App from "./App"; | |
import * as serviceWorker from "./serviceWorker"; | |
import { Provider } from "react-redux"; // holds that store | |
import "bootstrap/dist/css/bootstrap.css"; | |
import "@fortawesome/fontawesome-free/css/all.css"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import NewItemForm from "../../common-components/NewItemForm"; | |
import { | |
deleteHero, | |
loadHeroes, | |
postHero | |
} from "../../store/hero/hero-actions"; | |
import { connect } from "react-redux"; | |
import { Link } from "react-router-dom"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combineReducers, createStore, applyMiddleware } from "redux"; | |
import { heroReducer } from "./hero/hero-reducer"; | |
import { villainReducer } from "./villain/villain-reducer"; | |
import thunk from "redux-thunk"; // 3rd-party side-effects library. | |
import { composeWithDevTools } from "redux-devtools-extension"; // Redux devtools for time travel debugging. | |
/* | |
Merge all your reducers here. Name it rootReducer. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as types from "./hero-actions"; | |
/* | |
initalize your state with default values | |
*/ | |
let initialState = { | |
heroes: [], | |
fetching: false, | |
error: "" | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { addHero, getHeroes, removeHero, updateHero } from "./hero-service"; // services of hero module | |
/* | |
* action types | |
*/ | |
export const LOAD_HEROES_REQUEST = "LOAD_HEROES_REQUEST"; | |
export const LOAD_HEROES_SUCCESS = "LOAD_HEROES_SUCCESS"; | |
export const LOAD_HEROES_FAIL = "LOAD_HEROES_FAIL"; | |
export const CREATE_HERO_REQUEST = "CREATE_HERO_REQUEST"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { Redirect, Route, Switch } from "react-router"; | |
import Heroes from "./pages/heroes/Heroes"; | |
import EditHero from "./pages/heroes/EditHero"; | |
import Villains from "./pages/villains/Villains"; | |
import EditVillain from "./pages/villains/EditVillain"; | |
import createBrowserHistory from "history/createBrowserHistory"; | |
import { RouterStore, syncHistoryWithStore } from "mobx-react-router"; | |
import { Provider } from "mobx-react"; |