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 heroStore from "./stores/hero.store"; |
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 { types, flow, applySnapshot, onPatch, destroy } from "mobx-state-tree"; | |
import { | |
addHero, | |
getHero, | |
getHeroes, | |
removeHero, | |
updateHero | |
} from "./HeroService"; | |
import makeInspectable from "mobx-devtools-mst"; // Mobx State Tree dev tools |
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 React from "react"; | |
import { inject, observer } from "mobx-react"; | |
import HeroStore from "./../../stores/HeroStore"; | |
import { HeroModel } from "../../models/hero.model"; | |
import { Link } from "react-router-dom"; | |
import { toJS } from "mobx"; | |
import NewItemForm from "../../common-components/NewItemForm"; | |
export interface Props { | |
HeroStore: typeof HeroStore; |
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"; |
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 * 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 { 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 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 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 { 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", |