Opa是一个用于JavaScript的全栈式开源Web开发框架,让你编写安全和可扩展的Web应用程序。
Opa生成标准的Node.js/MongoDB应用程序,原生支持HTML5和CSS,并将现代Web应用程序编程的许多方面自动化。Ajax/Comet客户-服务器通信,事件驱动和非阻塞编程模型。
示例代码:
type message = { author : string ; text : string }@publish room = Network.cloud("room") : Network.network(message)user_update(x : message) = line = <div class="line"> <div class="user">{x.author}:</> <div class="message">{x.text}</> </> do Dom.transform([#conversation +<- line ]) Dom.scroll_to_bottom(#conversation)broadcast(author) = do Network.broadcast({~author text=Dom.get_value(#entry)}, room) Dom.clear_value(#entry)start() = author = Random.string(8) <div id=#header><div id=#logo></></> <div id=#conversation onready={_ -> Network.add_callback(user_update, room)}></> <div id=#footer> <input id=#entry onnewline={_ -> broadcast(author)} /> <div class="button" onclick={_ -> broadcast(author)}>Post</> </>server = Server.one_page_bundle("Chat", [@static_resource_directory("resources")], ["resources/css.css"], start)
评论