-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
62 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { add } from '../actions'; | ||
|
||
const addComponent = store => { | ||
const valueAdded = () => { | ||
const value = document.getElementById('text-value').value; | ||
document.getElementById('text-value').value = ''; | ||
store.dispatch(add(value)); | ||
}; | ||
|
||
const render = () => { | ||
const input = '<input type="text" id="text-value"/><button id="add-button">add</button>'; | ||
document.write(input); | ||
document.getElementById('add-button') | ||
.addEventListener('click', valueAdded); | ||
}; | ||
|
||
// store.subscribe(() => { | ||
// render(); | ||
// }); | ||
|
||
render(); | ||
}; | ||
|
||
export default addComponent; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const list = store => { | ||
const render = items => { | ||
const listItems = store.getState().list.values; | ||
|
||
const listLis = listItems.map(item => `<li>${item}</li>`).join(''); | ||
const html = `<ul>${listLis}</ul>`; | ||
|
||
document.getElementById('list').innerHTML = html; | ||
}; | ||
|
||
store.subscribe(() => { | ||
render(); | ||
}); | ||
|
||
render(); | ||
}; | ||
|
||
export default list; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import store from './store'; | ||
|
||
document.write('hi'); | ||
import page1 from './pages/page1'; | ||
|
||
page1(store); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import list from '../components/list'; | ||
import add from '../components/add'; | ||
|
||
const page1 = store => { | ||
document.write('<div id="list"></div><div id="add"></div>'); | ||
list(store); | ||
add(store); | ||
}; | ||
|
||
export default page1; |
This file contains 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
This file contains 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
This file contains 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