-
Notifications
You must be signed in to change notification settings - Fork 7
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
6 changed files
with
75 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
export function addComic(text) { | ||
return { | ||
type: 'ADD_COMIC', | ||
text | ||
}; | ||
} | ||
|
||
export function removeComic(comic) { | ||
return { | ||
type: 'REMOVE_COMIC', | ||
comic | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,4 +1,14 @@ | ||
import './style'; | ||
import { h, render } from 'preact'; | ||
import { Provider } from 'preact-redux'; | ||
import store from './store'; | ||
import App from './components/app'; | ||
import './style'; | ||
|
||
render(( | ||
<div id="outer"> | ||
<Provider store={store}> | ||
<App /> | ||
</Provider> | ||
</div> | ||
), document.body); | ||
|
||
export default App; |
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,6 @@ | ||
|
||
const EMPTY = {}; | ||
|
||
export default store => { | ||
return store || EMPTY; | ||
}; |
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 { createStore } from 'redux'; | ||
|
||
let ACTIONS = { | ||
ADD_COMIC: ({ comics, ...state }, { text }) => ({ | ||
comics: [...comics, { | ||
id: Math.random().toString(36).substring(2), | ||
text | ||
}], | ||
...state | ||
}), | ||
|
||
REMOVE_COMIC: ({ comics, ...state }, { comic }) => ({ | ||
comics: comics.filter( i => i!==comic ), | ||
...state | ||
}) | ||
}; | ||
|
||
const INITIAL = { | ||
comics: [] | ||
}; | ||
|
||
export default createStore( (state, action) => ( | ||
action && ACTIONS[action.type] ? ACTIONS[action.type](state, action) : state | ||
), INITIAL, window.devToolsExtension && window.devToolsExtension()); |
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,7 @@ | ||
import { bindActionCreators } from 'redux'; | ||
|
||
export function bindActions(actions) { | ||
return dispatch => ({ | ||
...bindActionCreators(actions, dispatch) | ||
}); | ||
} |