-
-
Save zaycker/0ef8f5e7da9467d588f031ea1fe291e3 to your computer and use it in GitHub Desktop.
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
import { LOAD_IMG, WALLPAPER_PATH_PREFIX } from '../../constants'; | |
const imageLoaded = dispatch => e => dispatch({ | |
type: LOAD_IMG, | |
payload: e.type === 'load' | |
}); | |
export default function (url) { | |
return (dispatch) => { | |
const bigImg = new Image(); | |
const imageLoadedDispatch = imageLoaded(dispatch); | |
bigImg.addEventListener('load', imageLoadedDispatch); | |
bigImg.addEventListener('error', imageLoadedDispatch); | |
bigImg.src = `${WALLPAPER_PATH_PREFIX}${url}`; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment