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
10
votes
3 answers

How do I create "options objects" in Scala.Js?

In idiomatic JavaScript it's common to have a function accept an "options object" as the last parameter. This is where you'd usually put all the option/seldom-used parameters, e.g. jQuery.ajax({ url: "http://www.example.com/foo", success:…
9
votes
2 answers

WebWorkers and Asynchronous shared data access. How in Scala.js?

Please consider a Scala.js class that contains a large JavaScript typed array called xArr. A process called p(xArr) consumes xArr as input but takes a long time to complete. In order to avoid script timeout warnings, p(xArr) runs in a Web…
Ben McKenneby
  • 481
  • 4
  • 15
9
votes
2 answers

java.lang.NoSuchMethodError: sbt.package$.Zero()Lsbt/Global$;

When using Scala.js 0.6.20 (addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.20") in project/plugins.sbt), the following error happens when trying to sbt import the project using sbt 0.13.15: java.lang.NoSuchMethodError:…
Gábor Bakos
  • 8,982
  • 52
  • 35
  • 52
9
votes
1 answer

How to export properties of shared case classes

I am trying to share a case class between server and client. I am using upickle on both ends. The objects and their data are nicely available on both ends. shared class case class Foo(var id : Long,var title: Description) However i need to export…
raphaëλ
  • 6,393
  • 2
  • 29
  • 35
8
votes
2 answers

leaflet map does not appear correctly until resize

I am using Leaflet with scalajs-leaflet facade on Binding.scala, and the map initializes/appears incorrectly. In order to reproduce the issue, i have prepared a lihaoyi/workbench page similar to that in scalajs-leaflet. First, download the forked…
mcku
  • 1,351
  • 12
  • 23
8
votes
1 answer

real JS classes in scala.js to develop webcomponents

I would like to develop some of the webcomponents in a Polymer 2.0 project with scala.js. While there is a wonderful demo-project on github demonstrating how it works with Polymer 1.0. I cannot get something similar to work with Polymer 2.0 and the…
SeDav
  • 761
  • 7
  • 19
8
votes
0 answers

Binding.scala vs Haoyi's Scala.Rx + ScalaTags

How does Binding.scala compare to the concept described here? Apart from the design descriptions one might compare their implementations of TodoMVC: Binding.scala Scala.Rx + ScalaTags Edit: By now I compared them to scalajs-react. I think react…
Tamriel
  • 1,337
  • 1
  • 9
  • 9
8
votes
1 answer

ScalaJS Uncaught TypeError: (0 , $m_Lorg_scalajs_jquery_package$(...).jQuery$1) is not a function

I am reading this tutorial for ScalaJS https://www.scala-js.org/tutorial/basic/ As you can see in my build.sbt, that I have included the reference to the jQuery library enablePlugins(ScalaJSPlugin) // This is an application with a main…
Knows Not Much
  • 30,395
  • 60
  • 197
  • 373
8
votes
1 answer

Can Scala.js not compile itself?

I'm going through the tutorial and it looks like Scala.js only runs under sbt. Are there bits of Scala.js (or the Scala environment generally) that are not written in Scala? Or cannot all the necessary bits go through Scala.js for some other…
Michael Lorton
  • 43,060
  • 26
  • 103
  • 144
8
votes
2 answers

uPickle and ScalaJS: sealed trait serialisation

I'm trying to get a basic upickle example to work and it seems I'm missing something here. I want to try out the example provided on the readme page for upickle import upickle._ sealed trait A @key("Bee") case class B(i: Int) extends A case object…
Jean-Philippe Pellet
  • 59,296
  • 21
  • 173
  • 234
8
votes
1 answer

Convert between scala class and Dynamic

How do you convert from a scala class to Dynamic, so unmentioned javascript functions can be called? How do you convert from Dynamic to a scala class?
ferk86
  • 2,325
  • 1
  • 23
  • 27
8
votes
1 answer

JQuery ajax calls on Scala.js

On my app, I need to make some ajax calls and I am trying to use jQuery for it. The way to do it would be by passing an object of type JQueryAjaxSettings to jQuery.ajax(url: String, settings: JQueryAjaxSettings). But I could not find a way to…
alcarv
  • 889
  • 6
  • 15
7
votes
1 answer

ReasonML vs Scala.js

So by reading the reasons why facebook choose OCaml to create Reason, I couldn't stop noting that Scala met all the requirements too. I'm not biased whatsoever, I know Scala, but I'm not a die hard scala advocate. I just like a nice type system, so…
caeus
  • 3,084
  • 1
  • 22
  • 36
7
votes
1 answer

Serving Scala.js assets

I've started new project with Finch and Scala.js, where backend and frontend need to share some code. And I'm concerned about a good way to serve JS produced by fastOptJS by Finch. Currently, I'm using custom SBT task which copies files from…
chuwy
  • 6,310
  • 4
  • 20
  • 29
7
votes
1 answer

How to set mainClass in ScalaJS build.sbt?

How to set mainClass in ScalaJS build.sbt? Currently I set the main class in build.sbt like this (see last line): enablePlugins(ScalaJSPlugin) name := "ScalaJS-Exp" scalaVersion := "2.11.7" libraryDependencies += "org.scala-js" %%% "scalajs-dom"…
user4955663
  • 1,039
  • 2
  • 13
  • 21
1
2
3
56 57