This project brings together two other projects: the excellent TreeLog from Lance and Channing Walton, and the pretty ReactTreeView component from Chandra Sekhar Kode in the scalajs-react-components project.
TreeLog is a way of displaying a program's log in a tree structure instead of the hopelessly
verbose sequential format we are usually cursed with. It is based on the Scalaz Writer
monad.
Although it is oriented towards algorithms with pure functions (like mathematical computations),
it can annotate tree nodes with messages for side-effects. Read more about it
at typelevel.
ReactTreeView is the UI part: this component supports expanding nodes, highlighting, and other nice features. It existed first as a normal ReactJS component, then was adapted into ScalaJS, meaning you can write your tree in Scala and it will be converted automatically into JavaScript. See the screenshot lower down to see what it looks like.
So, two tree projects: a match made in heaven? All TreeLog-ScalaJS really needs to do
is transform a scalaz.Tree
into a UI TreeItem
. The main code is in com.oranda.treelogui
.
There is some code here and in demo.components
that is copied from the
scalajs-react-components demo. The code in the treelog
package is copied straight from
the TreeLog project.
- Clone this project (or download and unzip).
- In the project's root, from the command-line run
sbt fastOptJS
. This will do all the Scala compilation and ScalaJS transpilation. - In your browser navigate to the project's index.html on the filesystem. (There is no need to run a server.) You should see:
- Download PhantomJS. This can run JavaScript outside a browser.
- Make sure the
phantomjs
executable is in yourPATH
environment variable. - In this project's root, from the command-line run
sbt test
.
Licensed under
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)