Skip to content

Instantly share code, notes, and snippets.

@zaycker
Forked from anonymous/index.js
Last active March 18, 2017 18:41
Show Gist options
  • Save zaycker/0ef8f5e7da9467d588f031ea1fe291e3 to your computer and use it in GitHub Desktop.
Save zaycker/0ef8f5e7da9467d588f031ea1fe291e3 to your computer and use it in GitHub Desktop.
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