-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refresh cache when re-enable a Binding or BindingSeq (fix #56)
- Loading branch information
Showing
4 changed files
with
133 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
Binding/src/test/scala/com/thoughtworks/binding/regression/Issue56.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.thoughtworks.binding.regression | ||
|
||
import com.thoughtworks.binding.Binding | ||
import com.thoughtworks.binding.Binding.{Var, Vars} | ||
import org.scalatest.{FreeSpec, Matchers} | ||
|
||
/** Test for https://github.com/ThoughtWorksInc/Binding.scala/issues/56 | ||
* @author 杨博 (Yang Bo) | ||
*/ | ||
final class Issue56 extends FreeSpec with Matchers { | ||
|
||
"test" in { | ||
var dataSource = Var[Int](100) | ||
val isEnabled = Var[Boolean](false) | ||
|
||
val mappedData = Binding { | ||
dataSource.bind + 1 | ||
} | ||
|
||
val result = Binding { | ||
if (isEnabled.bind) { | ||
mappedData.bind | ||
} else { | ||
0 | ||
} | ||
} | ||
|
||
result.watch() | ||
dataSource.value = 300 | ||
isEnabled.value = true | ||
result.value should be(301) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters