[erlang-questions] ANN: ezwebframe - an easy web framework

Joe Armstrong erlang@REDACTED
Wed Dec 19 18:28:05 CET 2012


On Wed, Dec 19, 2012 at 4:53 PM, Christopher Meiklejohn <
cmeiklejohn@REDACTED> wrote:

> On Wednesday, December 19, 2012 at 6:58 AM, Joe Armstrong wrote:
> > > But how the browser understand the commands you send from erlang
> process? for
> > > example here: {cmd, fill_div}
> >
> >
> > This is easy, here's an overview:
> >
> > - Convert the Erlang command to JSON
> > - send the JSON on the websocket uing Erlang
> > - receive the JSON in Javascript
> > - parse the JSON
> > - build a Javascript command
> > - execute the Javascript command
>
>
> Hi Joe,
>
> Thank you for putting this out there, I had a great time digging through
> the source code learning how the examples worked.
>
> I found it so inspiring that I went off and started playing around with
> some alternative approaches to handling the messages on the JavaScript
> side.  See here: [1]
>
> I've been exploring having the messages, when received on the JavaScript
> side, distributed using a pub/sub approach so the Erlang code doesn't have
> to know about JavaScript function names or argument lists.  I felt this
> made it feel a bit less RPC-ish and made it feel a bit more idiomatic.  See
> below for examples.
>
> One thing that I couldn't get a hold of when playing with your code was if
> you intended to write *most* of the client side application in Erlang and
> just write a thin-layer in JavaScript for event handling and
> DOM-manipulation or if you were leaving that up to the developer.
>

It depends on the application - if you look at the viserl1.html
it's all JavaScript and no Erlang - I was just playing around - I think for
latency
reasons you have to handle events in the browser (like drag and drop).

For a complex application I'd view the bowser as a black box that did
things then invent my own protocol to get it to do things.

In another experiment I just made a page with one function on it that
just does eval to anything you send it - this is just *too* general - but
then
again you'd only ever need one web page for *everything*

/Joe


>
> Again, thanks so much!
>
> --
>
> For example (partially taken from the README):
>
> Given the following Erlang:
>
> BrowserPid ! {client_count, 1}.
>
> The following message is sent on the wire:
> { type: "client_count", message: "1" }
>
> Followed by the following message published via AmplifyJS:
> amplify.publish("client_count", 1);
>
> This allows multiple consumers in your JavaScript application to subscribe
> to these messages and respond to them accordingly.  A subscriber could then
> call a method to update the DOM with that new value (via jQuery or
> whatever, this is no longer specific).
>
> [1] https://github.com/cmeiklejohn/piper
>
> --
>
> Christopher Meiklejohn
> Software Engineer
> Basho Technologies, Inc.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121219/aa81d990/attachment.htm>


More information about the erlang-questions mailing list