Skip to content

Commit

Permalink
Added support for Dotty
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfrog26 committed Aug 20, 2020
1 parent cde8389 commit c848c30
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: scala
sudo: required
dist: trusty
scala:
- 2.13.1
- 2.13.3
jdk:
- oraclejdk8
before_script:
Expand Down
13 changes: 8 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}

name in ThisBuild := "reactify"
organization in ThisBuild := "com.outr"
version in ThisBuild := "4.0.0"
scalaVersion in ThisBuild := "2.13.1"
crossScalaVersions in ThisBuild := List("2.13.1", "2.12.8", "2.11.12")
version in ThisBuild := "4.0.1-SNAPSHOT"
scalaVersion in ThisBuild := "2.13.3"
crossScalaVersions in ThisBuild := List("2.13.3", "2.12.12", "2.11.12")

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

val scalatestVersion = "3.2.0-M3"
val scalatestVersion = "3.2.2-M2"

lazy val reactify = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
Expand All @@ -36,5 +36,8 @@ lazy val reactify = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.nativeSettings(
nativeLinkStubs := true,
scalaVersion := "2.11.12",
crossScalaVersions := Seq("2.11.12")
crossScalaVersions := List("2.11.12")
)
.jvmSettings(
crossScalaVersions := List("2.13.3", "0.26.0-RC1", "2.12.12", "2.11.12")
)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.3.8
sbt.version=1.3.13
8 changes: 5 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "3.0.3")

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

addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.0.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0-M2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.1.1")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0-M2")

addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.1")
1 change: 1 addition & 0 deletions reactify/src/main/scala/reactify/Dep.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package reactify

import reactify.reaction.{Reaction, ReactionStatus}
import scala.language.implicitConversions

/**
* Dep allows creation of a dependent `Var` on another `Var` allowing conversion between the two. This can be useful for
Expand Down
5 changes: 5 additions & 0 deletions reactify/src/main/scala/reactify/Reactive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,8 @@ trait Reactive[T] {
}
}

object Reactive {
def fire[T](reactive: Reactive[T], value: T, previous: Option[T], reactions: List[Reaction[T]]): ReactionStatus = {
reactive.fire(value, previous, reactions)
}
}
12 changes: 7 additions & 5 deletions reactify/src/main/scala/reactify/Val.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ class Val[T] protected() extends Reactive[T] with Stateful[T] {
}
}

protected def set(value: => T): Unit = {
function = () => value
Val.evaluate(this, updating = false)
}
protected def set(value: => T): Unit = Val.set(this, value)

def static(value: T): Unit = {
function = () => value
Expand Down Expand Up @@ -61,6 +58,11 @@ object Val {
override def initialValue(): Option[Evaluating] = None
}

def set[T](v: Val[T], value: => T): Unit = {
v.function = () => value
evaluate(v, updating = false)
}

def apply[T](value: => T): Val[T] = {
val v = new Val[T]
v.set(value)
Expand All @@ -86,7 +88,7 @@ object Val {
v.previous = Option(v.evaluated)
v.evaluated = evaluated

v.fire(evaluated, v.previous, v.reactions())
Reactive.fire(v, evaluated, v.previous, v.reactions())
}
}

Expand Down
4 changes: 3 additions & 1 deletion reactify/src/main/scala/reactify/Var.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import reactify.bind.{BindSet, Binding}
import reactify.group.VarGroup
import reactify.transaction.Transaction

import scala.language.implicitConversions

/**
* Var represents the combination of `Val` and `Channel` into a stateful and mutable underlying value.
*
Expand All @@ -25,7 +27,7 @@ class Var[T] protected() extends Val[T]() with Mutable[T] {
*/
override def set(value: => T): Unit = {
Transaction.change(this, this.function, () => value)
super.set(value)
Val.set(this, value)
}

/**
Expand Down
4 changes: 3 additions & 1 deletion reactify/src/test/scala/test/BindingSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import org.scalatest.wordspec.AnyWordSpec
import reactify._
import reactify.bind.Binding

import scala.language.implicitConversions

class BindingSpec extends AnyWordSpec with Matchers {
"Bindings" when {
"dealing with a simple binding" should {
Expand Down Expand Up @@ -80,7 +82,7 @@ class BindingSpec extends AnyWordSpec with Matchers {
b() should be(50)
}
"verify b -> a no longer propagates" in {
b := "200"
b := 200
a() should be("100")
b() should be(200)
}
Expand Down
2 changes: 2 additions & 0 deletions reactify/src/test/scala/test/ChannelSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
import reactify.Channel

import scala.language.implicitConversions

class ChannelSpec extends AnyWordSpec with Matchers {
"Channels" should {
"notify when changed" in {
Expand Down
1 change: 1 addition & 0 deletions reactify/src/test/scala/test/DepSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.scalatest.wordspec.AnyWordSpec
import reactify._

import scala.collection.mutable.ListBuffer
import scala.language.implicitConversions

class DepSpec extends AnyWordSpec with Matchers {
"Deps" should {
Expand Down
2 changes: 2 additions & 0 deletions reactify/src/test/scala/test/DepSpecialSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
import reactify._

import scala.language.implicitConversions

class DepSpecialSpec extends AnyWordSpec with Matchers {
"Deps Special Use-Cases" when {
"combining Ints" should {
Expand Down
1 change: 1 addition & 0 deletions reactify/src/test/scala/test/TransactionSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
import reactify.Var
import reactify.transaction.Transaction
import scala.language.implicitConversions

class TransactionSpec extends AnyWordSpec with Matchers {
"Transactions" should {
Expand Down
2 changes: 2 additions & 0 deletions reactify/src/test/scala/test/TriggerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
import reactify.Trigger

import scala.language.implicitConversions

class TriggerSpec extends AnyWordSpec with Matchers {
"Triggers" should {
"handle simple invocations" in {
Expand Down
2 changes: 2 additions & 0 deletions reactify/src/test/scala/test/ValSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
import reactify._

import scala.language.implicitConversions

class ValSpec extends AnyWordSpec with Matchers {
"Vals" should {
"contain the proper value" in {
Expand Down
2 changes: 2 additions & 0 deletions reactify/src/test/scala/test/VarSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import reactify.group.VarGroup

import scala.collection.mutable.ListBuffer

import scala.language.implicitConversions

class VarSpec extends AnyWordSpec with Matchers {
lazy val lazyDouble: Var[Double] = Var(0.0)

Expand Down

0 comments on commit c848c30

Please sign in to comment.