Skip to content

Instantly share code, notes, and snippets.

@jpgorman
jpgorman / uploadFileSaga.js
Last active October 20, 2021 12:30
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)
}