Skip to content

Commit

Permalink
separate http request info from id
Browse files Browse the repository at this point in the history
  • Loading branch information
lue-bird committed Mar 30, 2024
1 parent 920b99d commit e370dd1
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 176 deletions.
14 changes: 7 additions & 7 deletions runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ export function programStart(appConfig: { ports: ElmPorts, domElement: HTMLEleme
case "RemoveDom": return (config: { path: number[] }) => {
removeDom(config.path)
}
case "RemoveHttpRequest": return (config: string) => {
const maybeAbortController = httpRequestAbortControllers[config]
case "RemoveHttpRequest": return (config: { url: string }) => {
const maybeAbortController = httpRequestAbortControllers[config.url]
if (maybeAbortController) {
maybeAbortController.abort()
}
Expand Down Expand Up @@ -276,6 +276,11 @@ export function programStart(appConfig: { ports: ElmPorts, domElement: HTMLEleme
}
})
}
case "AddHttpRequest": return (config: HttpRequest) => {
const abortController = new AbortController()
httpRequestAbortControllers[config.url] = abortController
return httpFetch(config, abortController)
}
case "AddListen": return (config: { tag: string, value: any }, sendToElm) => {
interfaceListenAddImplementation(config.tag)(config.value, sendToElm)
}
Expand Down Expand Up @@ -309,11 +314,6 @@ export function programStart(appConfig: { ports: ElmPorts, domElement: HTMLEleme
case "RandomUnsignedInt32sRequest": return (config: number) => {
return Promise.resolve(crypto.getRandomValues(new Uint32Array(config)))
}
case "HttpRequest": return (config: HttpRequest) => {
const abortController = new AbortController()
httpRequestAbortControllers[config.url] = abortController
return httpFetch(config, abortController)
}
case "WindowSizeRequest": return (_config: null) => {
return Promise.resolve({ width: window.innerWidth, height: window.innerHeight })
}
Expand Down
Loading

0 comments on commit e370dd1

Please sign in to comment.