Skip to content

Instantly share code, notes, and snippets.

View avrcoelho's full-sized avatar

André Coelho avrcoelho

View GitHub Profile
@avrcoelho
avrcoelho / uploadFileSaga.js
Created December 10, 2019 01:32 — forked from jpgorman/uploadFileSaga.js
Example of using redux-saga eventChannel with axios/fetch etc
import {eventChannel, END} from 'redux-saga'
function createUploaderChannel(key, files){
return eventChannel(emit => {
const onProgress = ({total, loaded}) => {
const percentage = Math.round((loaded * 100) / total)
emit(percentage)
}