diff options
author | 2009-03-08 13:41:55 -0400 | |
---|---|---|
committer | 2009-03-08 13:41:55 -0400 | |
commit | 5f77fc276c90321dec9e17ec483a1d8b11db3c96 (patch) | |
tree | 340a1e5251d1a16874ce49b5edf487714f45ff7b /tests/rpcO.ur | |
parent | b691dfb678a18667a623b45111683c480476051b (diff) |
RPC returning an option
Diffstat (limited to 'tests/rpcO.ur')
-rw-r--r-- | tests/rpcO.ur | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/rpcO.ur b/tests/rpcO.ur new file mode 100644 index 00000000..bc4b430e --- /dev/null +++ b/tests/rpcO.ur @@ -0,0 +1,25 @@ +table t : {A : int} + +fun main () : transaction page = + let + fun check () = + r <- oneRow (SELECT SUM(t.A) AS X FROM t); + return (if r.X < 0 then + (Some 3, None) + else + (None, Some "Hi")) + + fun show (t ::: Type) (_ : show t) (opt : option t) = + case opt of + None => <xml>None</xml> + | Some v => <xml>{[v]}</xml> + in + s <- source (None, None); + return <xml><body> + <button value="Get It On!" + onclick={r <- check (); + set s r}/><br/> + <br/> + Current: <dyn signal={p <- signal s; return <xml>{show p.1}, {show p.2}</xml>}/> + </body></xml> + end |