Questions tagged [scala.js]

Scala.js is a Scala to JavaScript compiler deemed production-ready as of version 0.6.0.

Scala.js compiles Scala code to JavaScript, allowing you to write your Web application entirely in Scala!

Noteworthy features:

  • Support all of Scala, modulo a few semantic differences
  • Very good interoperability with JavaScript code. For example, use jQuery and HTML5 from your Scala.js code, either in a typed or untyped way. Or create Scala.js objects and call their methods from JavaScript.
  • Integrated with sbt (including support for dependency management and incremental compilation)
  • Can be used with your favorite IDE for Scala
  • Generates Source Maps for a smooth debugging experience (step through your Scala code from within your browser supporting source maps)
  • Integrates Google Closure Compiler for producing minimal code for production.

Find out more at scala-js.org

845 questions
27
votes
2 answers

"Cannot find an implicit ExecutionContext" error in scala.js example app.

Here is an example from the Hands-on Scala.js ebook: package webpage import org.scalajs.dom.ext.Ajax import scala.scalajs.js import scala.scalajs.js.annotation.JSExport import scalatags.JsDom.all._ import org.scalajs.dom import…
qed
  • 22,298
  • 21
  • 125
  • 196
27
votes
1 answer

Futures in Scala.js

I tried to use Promises and Futures in Scala.js. Promise works, as soon as it comes to Futures I get warnings and errors. Try: val p1 = Promise[Int] val f1: Future[Int] = p1.future val p2 = Promise[Int] val f2: Future[Int] = p2.future val res1 = …
user2715145
24
votes
7 answers

Scala-JS for real web project

Has someone used Scala-JS in real web project but not only for plain JavaScript replacement in isolated env ? I would like to use Scala as much as possible (I wish I could). And seems Scala-JS claims to be that lib I could use (now) or in the…
ses
  • 13,174
  • 31
  • 123
  • 226
20
votes
2 answers

What is the difference between scala.js vs jscala?

There are two tools to compile Scala code right in the JavaScript: Scala.js and JScala. Both of them look great, and can work with non-trivial Scala code. What is the technical difference between them?
uhbif19
  • 3,139
  • 3
  • 26
  • 48
19
votes
2 answers

Whats the ScalaJS way to make an event occur in n milliseconds time?

Is it to use ScalaJS DOM and use the following? org.scalajs.dom.setTimeout( () => { // Work }, 1000) Is there another way or a better way within the context of ScalaJS?
Phil
  • 46,436
  • 33
  • 110
  • 175
18
votes
3 answers

Scalajs-react VS Xored Scalajs-react VS SRI

What is the difference between these Scala.js React.js libraries and why should I choose one over the other ? Xored Scalajs-react - Last commit was 8 months ago. So I'm guessing the development is not active anymore. Scalajs-react - Very active and…
user794783
  • 3,619
  • 7
  • 36
  • 58
15
votes
2 answers

Scala.js compilation destination

I'm working on a Scala.js cross project where the jvm folder represents my server application and jsrepresents my scala.js code. Whenever i compile my scala.js code via sbt crossJS/fastOptJS the compiled JS ends up in…
Joseph Moniz
  • 435
  • 3
  • 9
14
votes
1 answer

Unit testing Scala.js: Read test data from file residing in `test/resources`

In a Scala.js unit test, what is the easiest solution to load test data from a file residing in test/resources?
Rahel Lüthy
  • 6,837
  • 3
  • 36
  • 51
14
votes
1 answer

How do I port an existing Scala library to scalajs?

I'm new to Scala.js. I'd like to use the Argonaut json library. https://github.com/argonaut-io/argonaut Its only dependencies appear to be Monocle and Scalaz which both have versions compiled for Scala.js. I'd be happy to work on porting…
seanmcl
  • 9,740
  • 3
  • 39
  • 45
12
votes
2 answers

In a ScalaJs sbt build, is there any advantage to use webjars instead of npm or bower with 'Provided'?

When I first discovered webJars a few months ago I was super-skeptical that it would be be a viable way means of handling client-side dependencies given the enormous complexity of some of these builds/buildsystems, and given the frequency that js…
tacos_tacos_tacos
  • 10,277
  • 11
  • 73
  • 126
12
votes
2 answers

Best way to convert a case class to a js.Object

Say I have a case class: case class Name(first: String, last: String) val n1 = Name("John", "Doe") val n2 = Name("Mary", "Doe") and I have a java script object: @js.native trait MyJSObject extends js.Object { def add(name: js.Object): Unit =…
user79074
  • 4,937
  • 5
  • 29
  • 57
12
votes
1 answer

How to invoke nodejs modules from scala.js?

I'm trying to use scala.js + nw.js to write some application, and will use some node modules in scala.js. But I'm not sure how to do it. Say, there is module fs and I can write such code in Javascript: var fs =…
Freewind
  • 193,756
  • 157
  • 432
  • 708
12
votes
1 answer

How to embed javascript code directly in scala.js?

When I use scala.js to write scala code to generate javascript, I found it difficult sometimes to wrap the 3rd-party javascript code into scala objects. Is there anyway to embed some javascript code directly? e.g. as strings?
Freewind
  • 193,756
  • 157
  • 432
  • 708
12
votes
3 answers

How to parse a json string to a case class in scaja.js and vice versa

A JSON string: { "name": "Mike", "age": 111 } A case class: case class User(name:String, age:Int) If I use scala, there are many libraries can let me convert the JSON to the case class and vice versa, but they can't be used in…
Freewind
  • 193,756
  • 157
  • 432
  • 708
10
votes
1 answer

How to use AngularJS's module config with Scala.js?

In plain JavaScript you can do: angular.module('mymodule', ['ionic']) .config(function($someParam1, $someParam2) { // do something with the parameters } I am trying to do this with Scala.js. I tried the following three attempts, all of which…
rabejens
  • 7,594
  • 11
  • 56
  • 104
1
2 3
56 57