Skip to content

Commit

Permalink
upgrade liveviews
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethosa committed Aug 28, 2024
1 parent f345ae4 commit 2b8ab04
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/happyx/spa/renderer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ else:
proc js*(comp: BaseComponent, script: string) =
componentsResult[comp.uniqCompId] = "script:" & fmt"<script>{script}</script>"
proc rerender*(query, queryArr, reqMethod, inCookies, headers: auto, hostname, urlPath: string) =
echo "rerender for " & hostname
requestResult[hostname] = "rerender:" & liveviewRoutes[urlPath](
query, queryArr, reqMethod, inCookies, headers, nil
).children[1].ugly()
Expand Down
12 changes: 3 additions & 9 deletions src/happyx/ssr/liveviews/liveviews.nim
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,9 @@ proc handleLiveViews*(body: NimNode) =
componentsResult.del(comp.uniqCompId)
of 1:
eventHandlers[parsed["idx"].getInt](parsed["ev"])
when enableHttpBeast or enableHttpx:
let hostname = $int(req.client)
if requestResult.hasKey(hostname):
await wsClient.send($requestResult[hostname])
requestResult.del(hostname)
else:
if requestResult.hasKey(req.hostname):
await wsClient.send($requestResult[req.hostname])
requestResult.del(req.hostname)
if requestResult.hasKey(hostname):
await wsClient.send($requestResult[hostname])
requestResult.del(hostname)
else:
discard
body.add(wsMethod)
Expand Down

0 comments on commit 2b8ab04

Please sign in to comment.