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 { 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 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 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 * as React from "react"; | |
import { Hero } from "../../models/hero"; | |
import NewItemForm from "../../common-components/NewItemForm"; | |
import heroStore from "./../../stores/hero.store"; | |
import { NavLink, Link } from "react-router-dom"; | |
import { inject, observer } from "mobx-react"; | |
import { toJS } from "mobx"; | |
import { render } from "react-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 { decorate, observable, action } from "mobx"; | |
import { Hero } from "../models/hero"; | |
import { | |
addHero, | |
getHero, | |
getHeroes, | |
removeHero, | |
updateHero | |
} from "./hero-service"; |
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
<template> | |
<div class="container-fluid"> | |
<NewItemForm | |
:isShowNewItemForm="isShowNewItemForm" | |
:newItem="newItem" | |
@handleSubmit="onSubmit" | |
@handleShowNewItemForm="showNewItemForm" | |
@handleCancelForm="cancelForm" | |
></NewItemForm> |
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 "../../types"; | |
const getters = { | |
[types.GETTERS_INIT_HEROES]: state => state.heroes, // retrieves the current heroes array from the state | |
[types.GETTERS_INIT_HERO]: state => state.hero // retrieves the current hero object from the state | |
}; | |
export default getters; |
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 Vue from "vue"; // The Vue library | |
import Vuex from "vuex"; // The Vuex library | |
import heroes from "./modules/heroes"; // heroes module | |
import villains from "./modules/villains"; // villains is another module | |
Vue.use(Vuex); // using Vuex | |
export default new Vuex.Store({ | |
modules: { |
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
const state = { | |
heroes: [], // this heroes array must be initialized with and empty array. | |
hero: {} // this hero object must be initialized with and empty object. | |
}; | |
export default state; |