Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
let download$ = fromEvent(document, "click", ".downloadable").pipe(
map(e => months[e.target.attribues["data-month"]]),
map(month => ({
type: "download/start",
payload: { file: month + ".csv" }
})))
agent.on("download/start", ({ action }) => {
const { filename } = action.payload
return ajax({ url: "download.php?file=" + filename }).pipe(
map(result => ({
filename,
bytes: result.response
})))
},
{ concurrency: "serial", type: "download/complete" })
agent.on("download/complete", ({ action }) => {
const { filename, bytes } = action.payload
localStorage.set(filename, bytes)
console.log("Saved " + filename)
})
agent.subscribe(download$)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.