Udash is a Scala.js framework for building beautiful and maintainable web applications.
In cooperation with Scalatags and ScalaCSS libraries, Udash provides a type safe layer over HTML, CSS and JS with powerful data binding into DOM templates.
Scala is compiled to highly efficient JavaScript with no need to maintain js. It is also easy to use it with good, old JavaScript libraries like Twitter Bootstrap or jQuery.
Udash brings out of the box the RPC system with a shared data model and interfaces between frontend and backend, which boosts development and keeps code bases consistent.
Automatically synchronise user interface with your data model.
A client↔server communication based on typed interfaces. Bidirectional RPC via WebSockets out of the box.
Twitter Bootstrap components enriched by Udash features.
Udash serves a frontend routing mechanism. Just define matching from URL to view.
Translations served by the backend or compiled into JavaScript.
Generate a customized application, compile and try it out in 5 minutes.
Udash provides a complete support for your web application and the communication with the server but does not influence your backend implementation.
The whole framework code is available on GitHub under Apache v2 license.
With any IDE supporting the Scala language. No extra plugin needed.
Find more examples in the Udash Demos repository.
A good starting point is a generation of a project base with the Udash project generator. You can download it from here. The generator provides a command line interface which will collect some information about the project and prepare the project base for you.
Follow the below steps:
- Download the generator zip package and unzip it.
- Run it using the run.sh or run.bat script.
- Provide required data and start the project generation.
- Switch to a project directory in the command line.
- Open the SBT interpreter using the sbt command.
- Compile the project and run the Jetty server, if you selected the standard project version and asked the generator to create the Jetty launcher.
- If you selected only the frontend project, you can find static files in target/UdashStatic.
Read more in the Udash Developer's Guide.
The RPC client-server communication system for the Udash framework.
The Udash project tries to make frontend applications as type safe as possible. Thanks to the ScalaJS cross-compilation system, it is possible to share the code between the client and server applications. Udash RPC uses this feature to share:
- RPC interfaces with typed arguments and returned value.
- Data models, which can be used in RPC communication.
- Model validators, which can be used both in frontend and backend.
Udash RPC also provides a server for client communication that works out of the box. You only have to create the RPC interface and implement it - that is all, you do not have to worry about connection handling.
Read more in the Udash Developer's Guide.
The implementation is really simple. In the server RPC interface, add the ping method and implement this method in server code. Then you can call it from the client code.
import io.udash.rpc._
/** Shared RPC interface. */
@RPC
trait PingPongServerRPC {
def ping(id: Int): Future[Int]
}
/** Server-side implementation. */
class PingPongEndpoint extends PingPongServerRPC {
override def ping(id: Int): Future[Int] = {
TimeUnit.SECONDS.sleep(1)
Future.successful(id)
}
}
/** Client-side call. */
serverRpc.ping(123) onComplete {
case Success(response) => println(s"Pong($response)")
case Failure(ex) => println(s"PongError($ex)")
}
Find more examples in the Udash Demos repository.