@@ -28,6 +28,32 @@ class BasicSpec extends WordSpec with Matchers {
2828 changes should be(2 )
2929 lastChange should be(Some (" Test 2" ))
3030 }
31+ " map a Channel to another typed Channel" in {
32+ val c1 = Channel [String ]
33+ val c2 = c1.map(_.reverse)
34+
35+ var lastValue : Option [String ] = None
36+ c2.attach(v => lastValue = Some (v))
37+
38+ c1 := " Testing"
39+ lastValue should be(Some (" gnitseT" ))
40+ }
41+ " collect a Channel to another typed Channel" in {
42+ val IntRegex = """ (\d+)""" .r
43+ val c1 = Channel [String ]
44+ val c2 = c1.collect {
45+ case IntRegex (v) => v.toInt
46+ }
47+
48+ var lastValue : Option [Int ] = None
49+ c2.attach(v => lastValue = Some (v))
50+
51+ c1 := " Testing"
52+ lastValue should be(None )
53+
54+ c1 := " 50"
55+ lastValue should be(Some (50 ))
56+ }
3157 }
3258 " Vals" should {
3359 " contain the proper value" in {
@@ -253,7 +279,7 @@ class BasicSpec extends WordSpec with Matchers {
253279 }
254280 users := List (adam, betty, chris, debby)
255281
256- val fiveLetterNames = Val (users.collect {
282+ val fiveLetterNames = Val (users() .collect {
257283 case user if user.name.length == 5 => user.name()
258284 })
259285 fiveLetterNames() should be(List (" Betty" , " Chris" , " Debby" ))
@@ -383,7 +409,7 @@ class BasicSpec extends WordSpec with Matchers {
383409 }
384410 val complex : Var [Option [Complex ]] = Var [Option [Complex ]](None )
385411 var active = false
386- val enabled : Val [Boolean ] = Val (complex.flatMap(_.screen.map(_.active())).getOrElse(false ))
412+ val enabled : Val [Boolean ] = Val (complex.flatMap(_.screen() .map(_.active())).getOrElse(false ))
387413 enabled.attach(active = _)
388414 active should be(false )
389415 enabled() should be(false )
0 commit comments