diff --git a/src/kajax.nim b/src/kajax.nim index be230f0..414b9d2 100644 --- a/src/kajax.nim +++ b/src/kajax.nim @@ -7,10 +7,11 @@ import karax proc ajax(meth, url: cstring; headers: openarray[(cstring, cstring)]; data: cstring; - cont: proc (httpStatus: int; response: cstring)) = + cont: proc (httpStatus: int; response: cstring); + kxi: KaraxInstance = kxi) = proc contWrapper(httpStatus: int; response: cstring) = cont(httpStatus, response) - redraw() + redraw(kxi) type HttpRequest {.importc.} = ref object @@ -39,12 +40,14 @@ proc ajax(meth, url: cstring; headers: openarray[(cstring, cstring)]; proc ajaxPost*(url: cstring; headers: openarray[(cstring, cstring)]; data: cstring; - cont: proc (httpStatus: int, response: cstring)) = - ajax("POST", url, headers, data, cont) + cont: proc (httpStatus: int, response: cstring); + kxi: KaraxInstance = kxi) = + ajax("POST", url, headers, data, cont, kxi) proc ajaxGet*(url: cstring; headers: openarray[(cstring, cstring)]; - cont: proc (httpStatus: int, response: cstring)) = - ajax("GET", url, headers, nil, cont) + cont: proc (httpStatus: int, response: cstring); + kxi: KaraxInstance = kxi) = + ajax("GET", url, headers, nil, cont, kxi) proc toJson*[T](data: T): cstring {.importc: "JSON.stringify".} proc fromJson*[T](blob: cstring): T {.importc: "JSON.parse".}