update kajax.nim to use the 'kxi' context too

This commit is contained in:
Araq 2017-06-16 22:57:32 +02:00
commit 28c4f4b76a

View file

@ -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".}