[Ur] Looking for a minimal example using source / signal - eg, User types into a textbox, changes appear below in an <xml> fragment
Adam Chlipala
adamc at csail.mit.edu
Fri Aug 14 16:09:18 EDT 2015
The subject of your message seems to be a clear description of a
particular kind of example, which I will claim is already present in one
of the main demos:
http://www.impredicative.com/ur/demo/react.html
I think you've already found this one and the more complicated
'increment' demo. Maybe your question, then, has to do with the further
complication that you introduce below.
On 08/13/2015 11:38 PM, Stefan Scott Alexander wrote:
> (3) Initial coding attempt:
>
> I thought I could just make some minor modifications, to change the
> <cselect> in (1) to a <textbox>, as follows:
>
> fun main () =
> s <- source "";
> return <xml><body>
> <textbox source={s} onchange={v <- get s; alert ("Now it's " ^ v)}>
> </textbox>
>
> Hello, I'm <dyn signal={s <- signal s; return <xml>{[s]}</xml>}/>.
> </body></xml>
>
> However, this is giving lots of compile errors.
The problem here is just that you need <ctextbox> instead of <textbox>.
The 'c' is for "client-side scripting."
> (4) Ultimately, what I want to develop is:
>
> (a) a <textbox> on the client, called `txbx`, which the user can
> change by typing
>
> (b) a table `t` on the server, which will be "live-queryable" using
> the <textbox>:
>
> (c) when user types something different in the <textbox>, there is an
> <xml> fragment below the <textbox> which instantly changes:
>
> eg - the <xml> fragment might be something like this:
>
> return queryX1 (SELECT Nam FROM t WHERE Nam LIKE '*' ^ {[txbx]} '*')
> (fn r => <xml>{[r.Nam]}<br/></xml>);
>
> I can't even get the simpler case (3) above to work. After I get (3)
> to work, then I can try (4).
It's only possible to implement server-side interaction through RPCs.
You probably want an event handler that blocks on an RPC result and then
updates client-side sources appropriately when the results come in.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20150814/91d0a14d/attachment.html>
More information about the Ur
mailing list