Skip to content

Commit c848c30

Browse files
committed
Added support for Dotty
1 parent cde8389 commit c848c30

File tree

16 files changed

+46
-17
lines changed

16 files changed

+46
-17
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language: scala
22
sudo: required
33
dist: trusty
44
scala:
5-
- 2.13.1
5+
- 2.13.3
66
jdk:
77
- oraclejdk8
88
before_script:

build.sbt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
22

33
name in ThisBuild := "reactify"
44
organization in ThisBuild := "com.outr"
5-
version in ThisBuild := "4.0.0"
6-
scalaVersion in ThisBuild := "2.13.1"
7-
crossScalaVersions in ThisBuild := List("2.13.1", "2.12.8", "2.11.12")
5+
version in ThisBuild := "4.0.1-SNAPSHOT"
6+
scalaVersion in ThisBuild := "2.13.3"
7+
crossScalaVersions in ThisBuild := List("2.13.3", "2.12.12", "2.11.12")
88

99
publishTo in ThisBuild := sonatypePublishTo.value
1010
sonatypeProfileName in ThisBuild := "com.outr"
@@ -22,7 +22,7 @@ developers in ThisBuild := List(
2222
Developer(id="darkfrog", name="Matt Hicks", email="matt@matthicks.", url=url("http://matthicks.com"))
2323
)
2424

25-
val scalatestVersion = "3.2.0-M3"
25+
val scalatestVersion = "3.2.2-M2"
2626

2727
lazy val reactify = crossProject(JVMPlatform, JSPlatform, NativePlatform)
2828
.crossType(CrossType.Pure)
@@ -36,5 +36,8 @@ lazy val reactify = crossProject(JVMPlatform, JSPlatform, NativePlatform)
3636
.nativeSettings(
3737
nativeLinkStubs := true,
3838
scalaVersion := "2.11.12",
39-
crossScalaVersions := Seq("2.11.12")
39+
crossScalaVersions := List("2.11.12")
40+
)
41+
.jvmSettings(
42+
crossScalaVersions := List("2.13.3", "0.26.0-RC1", "2.12.12", "2.11.12")
4043
)

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.3.8
1+
sbt.version=1.3.13

project/plugins.sbt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
22
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "3.0.3")
33

4-
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8.1")
4+
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.4")
55
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
66

77
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
88
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.0.0")
9-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1")
10-
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0-M2")
9+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.1.1")
10+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0-M2")
11+
12+
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.1")

reactify/src/main/scala/reactify/Dep.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package reactify
22

33
import reactify.reaction.{Reaction, ReactionStatus}
4+
import scala.language.implicitConversions
45

56
/**
67
* Dep allows creation of a dependent `Var` on another `Var` allowing conversion between the two. This can be useful for

reactify/src/main/scala/reactify/Reactive.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,8 @@ trait Reactive[T] {
132132
}
133133
}
134134

135+
object Reactive {
136+
def fire[T](reactive: Reactive[T], value: T, previous: Option[T], reactions: List[Reaction[T]]): ReactionStatus = {
137+
reactive.fire(value, previous, reactions)
138+
}
139+
}

reactify/src/main/scala/reactify/Val.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ class Val[T] protected() extends Reactive[T] with Stateful[T] {
2424
}
2525
}
2626

27-
protected def set(value: => T): Unit = {
28-
function = () => value
29-
Val.evaluate(this, updating = false)
30-
}
27+
protected def set(value: => T): Unit = Val.set(this, value)
3128

3229
def static(value: T): Unit = {
3330
function = () => value
@@ -61,6 +58,11 @@ object Val {
6158
override def initialValue(): Option[Evaluating] = None
6259
}
6360

61+
def set[T](v: Val[T], value: => T): Unit = {
62+
v.function = () => value
63+
evaluate(v, updating = false)
64+
}
65+
6466
def apply[T](value: => T): Val[T] = {
6567
val v = new Val[T]
6668
v.set(value)
@@ -86,7 +88,7 @@ object Val {
8688
v.previous = Option(v.evaluated)
8789
v.evaluated = evaluated
8890

89-
v.fire(evaluated, v.previous, v.reactions())
91+
Reactive.fire(v, evaluated, v.previous, v.reactions())
9092
}
9193
}
9294

reactify/src/main/scala/reactify/Var.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import reactify.bind.{BindSet, Binding}
66
import reactify.group.VarGroup
77
import reactify.transaction.Transaction
88

9+
import scala.language.implicitConversions
10+
911
/**
1012
* Var represents the combination of `Val` and `Channel` into a stateful and mutable underlying value.
1113
*
@@ -25,7 +27,7 @@ class Var[T] protected() extends Val[T]() with Mutable[T] {
2527
*/
2628
override def set(value: => T): Unit = {
2729
Transaction.change(this, this.function, () => value)
28-
super.set(value)
30+
Val.set(this, value)
2931
}
3032

3133
/**

reactify/src/test/scala/test/BindingSpec.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import org.scalatest.wordspec.AnyWordSpec
55
import reactify._
66
import reactify.bind.Binding
77

8+
import scala.language.implicitConversions
9+
810
class BindingSpec extends AnyWordSpec with Matchers {
911
"Bindings" when {
1012
"dealing with a simple binding" should {
@@ -80,7 +82,7 @@ class BindingSpec extends AnyWordSpec with Matchers {
8082
b() should be(50)
8183
}
8284
"verify b -> a no longer propagates" in {
83-
b := "200"
85+
b := 200
8486
a() should be("100")
8587
b() should be(200)
8688
}

reactify/src/test/scala/test/ChannelSpec.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import org.scalatest.matchers.should.Matchers
44
import org.scalatest.wordspec.AnyWordSpec
55
import reactify.Channel
66

7+
import scala.language.implicitConversions
8+
79
class ChannelSpec extends AnyWordSpec with Matchers {
810
"Channels" should {
911
"notify when changed" in {

0 commit comments

Comments
 (0)