Skip to content

Commit f6d234e

Browse files
authored
Merge pull request #185 from Atry/compatiblity-fix
Revert 252da61 in case of breaking source code backward-compatibility
2 parents 50bbd80 + 6d78ac4 commit f6d234e

File tree

13 files changed

+132
-138
lines changed

13 files changed

+132
-138
lines changed

Binding/src/main/scala/com/thoughtworks/binding/Binding.scala

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ object Binding extends MonadicFactory.WithTypeClass[Monad, Binding] {
363363
}
364364

365365
@inline
366-
override def value: B = {
366+
override protected def value: B = {
367367
cache
368368
}
369369

@@ -442,7 +442,7 @@ object Binding extends MonadicFactory.WithTypeClass[Monad, Binding] {
442442
cache = f(upstream.value)
443443
}
444444

445-
override def value: B = {
445+
override protected def value: B = {
446446
@tailrec
447447
@inline
448448
def tailrecGetValue(binding: Binding[B]): B = {
@@ -615,7 +615,7 @@ object Binding extends MonadicFactory.WithTypeClass[Monad, Binding] {
615615
override protected def addPatchedListener(listener: PatchedListener[Nothing]): Unit = {}
616616

617617
@inline
618-
override def value = Nil
618+
override protected def value = Nil
619619
}
620620

621621
private[Binding] abstract class ValueProxy[B] extends Seq[B] with HasCache[Binding[B]] {
@@ -726,7 +726,7 @@ object Binding extends MonadicFactory.WithTypeClass[Monad, Binding] {
726726
}
727727

728728
@inline
729-
override def value = new FlatProxy(cacheData)
729+
override protected def value = new FlatProxy(cacheData)
730730

731731
@inline
732732
private def flatIndex(oldCache: Cache, upstreamBegin: Int, upstreamEnd: Int): Int = {
@@ -848,7 +848,7 @@ object Binding extends MonadicFactory.WithTypeClass[Monad, Binding] {
848848
} yield f(a))(collection.breakOut)
849849
}
850850

851-
override def value: Seq[B] = {
851+
override protected def value: Seq[B] = {
852852
val cacheData0 = cacheData
853853
new ValueProxy[B] {
854854
var cacheData = cacheData0
@@ -918,7 +918,7 @@ object Binding extends MonadicFactory.WithTypeClass[Monad, Binding] {
918918
private val publisher = new SafeBuffer[ChangedListener[Int]]
919919

920920
@inline
921-
override def value: Int = bindingSeq.value.length
921+
override protected def value: Int = bindingSeq.value.length
922922

923923
@inline
924924
override protected def removeChangedListener(listener: ChangedListener[Int]): Unit = {
@@ -961,7 +961,7 @@ object Binding extends MonadicFactory.WithTypeClass[Monad, Binding] {
961961
private val publisher = new SafeBuffer[ChangedListener[Seq[Element]]]
962962

963963
@inline
964-
override def value: Seq[Element] = upstream.value
964+
override protected def value: Seq[Element] = upstream.value
965965

966966
@inline
967967
override protected def removeChangedListener(listener: ChangedListener[Seq[Element]]): Unit = {
@@ -1016,18 +1016,13 @@ object Binding extends MonadicFactory.WithTypeClass[Monad, Binding] {
10161016
removePatchedListener(Binding.DummyPatchedListener)
10171017
}
10181018

1019-
/**
1020-
* Returns the current value of this [[BindingSeq]].
1021-
*
1022-
* @note This method must not be invoked inside a `@dom` method body or a `Binding { ... }` block..
1023-
*/
1024-
def value: Seq[A]
1019+
/** Returns the current value of this [[BindingSeq]]. */
1020+
protected def value: Seq[A]
10251021

10261022
/** Returns the current value of this [[BindingSeq]].
10271023
*
10281024
* @note This method is used for internal testing purpose only.
10291025
*/
1030-
@deprecated(message = "Use [[value]] instead", since = "11.0.0")
10311026
private[binding] def get: Seq[A] = value
10321027

10331028
protected def removePatchedListener(listener: PatchedListener[A]): Unit
@@ -1377,7 +1372,7 @@ object Binding extends MonadicFactory.WithTypeClass[Monad, Binding] {
13771372
override def length: Constant[Int] = Constant(1)
13781373

13791374
@inline
1380-
override def value = SingleSeq(upstream.value)
1375+
override protected def value = SingleSeq(upstream.value)
13811376

13821377
@inline
13831378
override protected def removePatchedListener(listener: PatchedListener[A]): Unit = {
@@ -1427,7 +1422,7 @@ object Binding extends MonadicFactory.WithTypeClass[Monad, Binding] {
14271422
}
14281423

14291424
@inline
1430-
override def value: Unit = ()
1425+
override protected def value: Unit = ()
14311426

14321427
}
14331428

@@ -1520,15 +1515,14 @@ trait Binding[+A] {
15201515
*/
15211516
final def bind: A = macro Binding.Macros.bind
15221517

1523-
@deprecated(message = "Use [[value]] instead", since = "11.0.0")
15241518
private[binding] def get: A = value
15251519

15261520
/**
15271521
* Returns the current value of this [[Binding]]
15281522
*
15291523
* @note This method must not be invoked inside a `@dom` method body or a `Binding { ... }` block..
15301524
*/
1531-
def value: A
1525+
protected def value: A
15321526

15331527
protected def removeChangedListener(listener: Binding.ChangedListener[A]): Unit
15341528

Binding/src/test/scala/com/thoughtworks/binding/BindingTest.scala

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ final class BindingTest extends FreeSpec with Matchers {
5353
}
5454
hello.watch()
5555

56-
assert(hello.value == "Hello, World!")
56+
assert(hello.get == "Hello, World!")
5757
target.value = "Each"
58-
assert(hello.value == "Hello, Each!")
58+
assert(hello.get == "Hello, Each!")
5959
}
6060

6161
"TripleBinding" in {
@@ -64,10 +64,10 @@ final class BindingTest extends FreeSpec with Matchers {
6464
input.bind + input.bind + input.bind
6565
}
6666
output.watch()
67-
assert(output.value == 0)
67+
assert(output.get == 0)
6868
for (i <- 0 until 10) {
6969
input.value = i
70-
assert(output.value == i * 3)
70+
assert(output.get == i * 3)
7171
}
7272
}
7373

@@ -89,7 +89,7 @@ final class BindingTest extends FreeSpec with Matchers {
8989

9090
var resultChanged = 0
9191

92-
assert(expr1.value == 0)
92+
assert(expr1.get == 0)
9393

9494
addChangedListener(expr1, new ChangedListener[Any] {
9595
override def changed(event: ChangedEvent[Any]): Unit = {
@@ -98,12 +98,12 @@ final class BindingTest extends FreeSpec with Matchers {
9898
})
9999

100100
assert(resultChanged == 0)
101-
assert(expr1.value == 32100)
101+
assert(expr1.get == 32100)
102102

103103
expr3.value = 4000
104104

105105
assert(resultChanged == 1)
106-
assert(expr1.value == 34100)
106+
assert(expr1.get == 34100)
107107

108108
}
109109

@@ -122,10 +122,10 @@ final class BindingTest extends FreeSpec with Matchers {
122122
resultChanged += 1
123123
}
124124
})
125-
assert(result.value == 0.5)
125+
assert(result.get == 0.5)
126126
assert(resultChanged == 0)
127127
source.value = 4.0
128-
assert(result.value == 0.25)
128+
assert(result.get == 0.25)
129129
assert(resultChanged == 1)
130130
}
131131

@@ -218,7 +218,7 @@ final class BindingTest extends FreeSpec with Matchers {
218218
assert(event.that == Seq("ForYield 0/3", "ForYield 1/3", "ForYield 2/3"))
219219
}
220220
assert(
221-
mapped.value == Seq(
221+
mapped.get == Seq(
222222
"ForYield 0/2",
223223
"ForYield 1/2",
224224
"ForYield 0/3",
@@ -234,7 +234,7 @@ final class BindingTest extends FreeSpec with Matchers {
234234
))
235235
prefix.value = "3"
236236
assert(sourceEvents.length == 4)
237-
assert(mapped.value == Seq("3 0/2", "3 1/2", "3 0/4", "3 1/4", "3 2/4", "3 3/4"))
237+
assert(mapped.get == Seq("3 0/2", "3 1/2", "3 0/4", "3 1/4", "3 2/4", "3 3/4"))
238238

239239
removePatchedListener(mapped, mappedEvents.listener)
240240
removePatchedListener(source, sourceEvents.listener)
@@ -595,7 +595,7 @@ final class BindingTest extends FreeSpec with Matchers {
595595
val myVars = Vars(1, 2, 100, 3)
596596
val filtered = myVars.withFilter(_ < 10).map(x => x)
597597
filtered.watch()
598-
assert(filtered.value == Seq(1, 2, 3))
598+
assert(filtered.get == Seq(1, 2, 3))
599599
}
600600
}
601601

@@ -620,21 +620,21 @@ final class BindingTest extends FreeSpec with Matchers {
620620
c.watch()
621621

622622
var result: (Int, Int) = null
623-
assert((3, 1) == ((c.value, count)))
623+
assert((3, 1) == ((c.get, count)))
624624

625625
a.value = 4
626-
assert((6, 2) == ((c.value, count)))
626+
assert((6, 2) == ((c.get, count)))
627627

628628
b.value = 3
629-
assert((7, 3) == ((c.value, count)))
629+
assert((7, 3) == ((c.get, count)))
630630

631631
(0 to 100).foreach { i =>
632632
a.value = i
633633
}
634-
assert((103, 104) == ((c.value, count)))
634+
assert((103, 104) == ((c.get, count)))
635635

636636
b.value = 4
637-
assert((104, 105) == ((c.value, count)))
637+
assert((104, 105) == ((c.get, count)))
638638
}
639639

640640
"multi to one dependencies" in {
@@ -658,15 +658,15 @@ final class BindingTest extends FreeSpec with Matchers {
658658
}
659659
Binding.BindingInstances.ap _
660660
aPlusOneTimesBPlusOn.watch()
661-
aPlusOneTimesBPlusOn.value should be((100 + 1) * (200 + 1))
661+
aPlusOneTimesBPlusOn.get should be((100 + 1) * (200 + 1))
662662
aFlushCount should be(1)
663663
bFlushCount should be(1)
664664
a.value = 500
665-
aPlusOneTimesBPlusOn.value should be((500 + 1) * (200 + 1))
665+
aPlusOneTimesBPlusOn.get should be((500 + 1) * (200 + 1))
666666
aFlushCount should be(2)
667667
bFlushCount should be(2)
668668
b.value = 600
669-
aPlusOneTimesBPlusOn.value should be((500 + 1) * (600 + 1))
669+
aPlusOneTimesBPlusOn.get should be((500 + 1) * (600 + 1))
670670
aFlushCount should be(2)
671671
bFlushCount should be(3)
672672

@@ -680,15 +680,15 @@ final class BindingTest extends FreeSpec with Matchers {
680680
if myVar < 10
681681
} yield myVar
682682
filtered.watch()
683-
assert(filtered.value == Seq(1, 2, 3))
683+
assert(filtered.get == Seq(1, 2, 3))
684684
}
685685
domMethod()
686686
}
687687

688688
"flatMap" in {
689689
val flatMapped = Constants(Constants(1, 2), Constants(), Constants(3)).flatMap(identity)
690690
flatMapped.watch()
691-
flatMapped.value should be(Seq(1, 2, 3))
691+
flatMapped.get should be(Seq(1, 2, 3))
692692
}
693693

694694
"foreach" in {

Binding/src/test/scala/com/thoughtworks/binding/regression/InsertThenClear.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ final class InsertThenClear extends FreeSpec with Matchers {
3939

4040
val mapped = items.map(-_)
4141
mapped.watch()
42-
assert(mapped.value == Seq(-1, -2, -3, -4, -5, -6, -7, -8, -9, -10))
42+
assert(mapped.get == Seq(-1, -2, -3, -4, -5, -6, -7, -8, -9, -10))
4343

4444
items.value.insertAll(3, 100 to 103)
45-
assert(mapped.value == Seq(-1, -2, -3, -100, -101, -102, -103, -4, -5, -6, -7, -8, -9, -10))
45+
assert(mapped.get == Seq(-1, -2, -3, -100, -101, -102, -103, -4, -5, -6, -7, -8, -9, -10))
4646

4747
items.value.clear()
48-
assert(mapped.value == Seq.empty)
48+
assert(mapped.get == Seq.empty)
4949
}
5050
}
5151

Binding/src/test/scala/com/thoughtworks/binding/regression/Issue56.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class Issue56 extends FreeSpec with Matchers {
2828
result.watch()
2929
dataSource.value = 300
3030
isEnabled.value = true
31-
result.value should be(301)
31+
result.get should be(301)
3232
}
3333

3434
}

Binding/src/test/scala/com/thoughtworks/binding/regression/Zhihu50863924.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ final class Zhihu50863924 extends FreeSpec with Matchers {
5656
}
5757

5858
render.watch()
59-
assert(render.value == Left("None here!"))
59+
assert(render.get == Left("None here!"))
6060
value.value = Some("Changed")
61-
assert(render.value == Right("Changed"))
61+
assert(render.get == Right("Changed"))
6262
assert(renderCount0 == 1)
6363
assert(renderCount1 == 1)
6464
}

JsPromiseBinding/src/main/scala/com/thoughtworks/binding/JsPromiseBinding.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ final class JsPromiseBinding[A](thenable: Thenable[A]) extends Binding[Option[Ei
119119

120120
private val publisher = new SafeBuffer[ChangedListener[Option[Either[Any, A]]]]
121121

122-
override def value = cache
122+
override protected def value = cache
123123

124124
override protected def removeChangedListener(listener: ChangedListener[Option[Either[Any, A]]]): Unit = {
125125
publisher -= listener

dom/src/test/scala/com/thoughtworks/binding/Issue113.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Issue113 extends FreeSpec with Matchers {
77
"name clash should be avoided" in {
88
val dialog = dialogUI("id")
99
dialog.watch()
10-
dialog.value.outerHTML should be ("""<aside id="id">
10+
dialog.get.outerHTML should be ("""<aside id="id">
1111
<div>
1212
<fieldset>
1313
</fieldset>

dom/src/test/scala/com/thoughtworks/binding/Issue118.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class Issue118 extends FreeSpec with Matchers {
88
"XHTML boolean attributes should compile" in {
99
@dom val elementWithBooleanAttributes = <textarea hidden="hidden" draggable="true" readOnly="readOnly"></textarea>
1010
elementWithBooleanAttributes.watch()
11-
elementWithBooleanAttributes.value.getAttribute("draggable") should be("true")
12-
elementWithBooleanAttributes.value.getAttribute("hidden") should be("hidden")
13-
elementWithBooleanAttributes.value.getAttribute("readOnly") should be("readOnly")
11+
elementWithBooleanAttributes.get.getAttribute("draggable") should be("true")
12+
elementWithBooleanAttributes.get.getAttribute("hidden") should be("hidden")
13+
elementWithBooleanAttributes.get.getAttribute("readOnly") should be("readOnly")
1414
}
1515
}

dom/src/test/scala/com/thoughtworks/binding/Issue21.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ class Issue21 extends FreeSpec with Matchers {
1010
"dashed-id should compile" in {
1111
@dom def invalidId: Binding[html.Div] = <div id="dashed-id" class={ s"${`dashed-id`.tagName}-1" }></div>
1212
invalidId.watch()
13-
invalidId.value.className should be("DIV-1")
13+
invalidId.get.className should be("DIV-1")
1414
}
1515
}

0 commit comments

Comments
 (0)