Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
Signed-off-by: George Lemon <[email protected]>
  • Loading branch information
georgelemon committed Mar 22, 2024
1 parent afc2d6c commit 4927dfe
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/tim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@ const
const localStorage* = CacheSeq"LocalStorage"

macro initCommonStorage*(x: untyped) =
## Initializes a common localStorage that can be
## shared between controllers
if x.kind == nnkStmtList:
add localStorage, x[0]
elif x.kind == nnkTableConstr:
add localStorage, x
else: error("Invalid common storage initializer. Use `{}`, or `do` block")

template `&*`*(n: untyped): untyped =
## Compile-time localStorage initializer
## that helps reusing shareable data.
##
## Once merged it calls `%*` macro from `std/json`
## for converting NimNode to JsonNode
macro toLocalStorage(x: untyped): untyped =
## Compile-time localStorage initializer
## that helps reusing shareable data.
##
## Once merged it calls `%*` macro from `std/json`
## for converting NimNode to JsonNode
if x.kind in {nnkTableConstr, nnkCurly}:
var shareLocalNode: NimNode
if localStorage.len > 0:
Expand Down

0 comments on commit 4927dfe

Please sign in to comment.