You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-3Lines changed: 12 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,16 @@
1
1
scala-js-dom
2
2
============
3
3
4
-
Provides a nice statically typed interface to the DOM such that it can be called from Scala code without resorting to `js.Dynamic`.
4
+
Scala-js-dom provides a nice statically typed interface to the DOM such that it can be called from Scala code without resorting to `js.Dynamic`. All javascript globals functions, singletons and classes are members of the `org.scalajs.dom`, e.g.
5
5
6
-
Also contains useful extension methods in `org.scalajs.dom.extensions`, which allow the DOM api to be used in a more idiomatic and fluent way. The goal of this project is to provide a thin-but-idiomatic-scala interface to modern browser APIs. In particular:
6
+
```scala
7
+
importorg.scalajs.dom
8
+
dom.alert("HAI")
9
+
```
10
+
11
+
Will cause a javascript alert box saying `HAI` to appear. Other javascript classes and objects can be similarly accessed e.g. `new dom.XMLHttpRequest()` to perform a new Ajax request, `dom.document` to access the global `document` object, or `dom.setInterval(() => ???, 1000)` to schedule a recurring task every second. The names of these functions/singletons/classes match their Javascript equivalents exactly, so if you want to know how to do something (e.g. "how do I open a websocket connection") the syntax is the same as if you were using raw Javascript.
12
+
13
+
Scala-js-dom also contains useful extension methods in `org.scalajs.dom.extensions`, which allow the DOM api to be used in a more idiomatic and fluent way. The goal of this project is to provide a thin-but-idiomatic-scala interface to modern browser APIs. In particular:
7
14
8
15
- Deprecated properties/methods/types will not be present.
9
16
- IE-only, Chrome-only, FF-only, and in general browser-specific attributes will not be present.
@@ -12,6 +19,8 @@ Also contains useful extension methods in `org.scalajs.dom.extensions`, which al
12
19
- Read-only members should be `def`, and not-directly-instantiable classes should have `private` constructors.
13
20
-`org.scalajs.dom` contains DOM class/member stubs, while `org.scalajs.dom.extensions` contains implicit conversions and useful Scala types (e.g. `Color`) to make usage of the DOM more idiomatic Scala.
14
21
22
+
Apart from `Color`, Scala-js-dom contains some useful helpers in `org.scalajs.dom.extensions` that serve no purpose other than to make your use of the DOM more pleasant. Examples include the `Ajax.get` and `Ajax.post` methods which let you avoid messing with `dom.XMLHttpRequest` directly, or `KeyCodes` which provides a nice list of the keycodes that result from pressing various keys on the keyboard.
23
+
15
24
Usage
16
25
-----
17
26
@@ -21,7 +30,7 @@ Add the following to your sbt build definition:
21
30
22
31
then enjoy the types available in `org.scalajs.dom`.
23
32
24
-
See also [roll](https://github.com/lihaoyi/roll) ([live demo](http://lihaoyi.github.io/roll/)) and [scala-js-games](https://github.com/lihaoyi/scala-js-games) for an example of its use. There remain lots more cleanup to do, but this should be a reasonable place to start from. Pull requests/forks are welcome!
33
+
See also [roll](https://github.com/lihaoyi/roll) ([live demo](http://lihaoyi.github.io/roll/)) and [scala-js-games](https://github.com/lihaoyi/scala-js-games) for an example of its use. [Scala-js-fiddle](http://www.scala-js-fiddle.com/) also contains a pile of [fun examples](http://www.scala-js-fiddle.com/gist/9405209/Oscilloscope.scala) that demonstate its usage. Pull requests/forks are welcome!
0 commit comments