Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding.scala - how to get updating count from Vars

I have a Vars binding statement, like so

val data: Vars[Contact] = Vars.empty[Contact]

I'm trying to show the number of elements like so:

<div>{data.all.bind.size}</div>

But this produces a complication error

type mismatch;
[error]  found   : com.thoughtworks.binding.Binding[App.this.data.All[App.this.Contact]]
[error]     (which expands to)  com.thoughtworks.binding.Binding[scala.collection.mutable.Buffer[_ <: App.this.Contact]]
[error]  required: com.thoughtworks.binding.Binding[scala.collection.mutable.Buffer[_$6]] where type _$6 <: App.this.Contact
[error]         {this.data.all.bind.size}</div>

How to make this work?

Update

trying to use String as type for Vars binding, same outcome

type mismatch;
[error]  found   : com.thoughtworks.binding.Binding[App.this.data.All[String]]
[error]     (which expands to)  com.thoughtworks.binding.Binding[scala.collection.mutable.Buffer[_ <: String]]
[error]  required: com.thoughtworks.binding.Binding[scala.collection.mutable.Buffer[_$6]] where type _$6 <: String
[error]         {this.data.all.bind.size}</div>

Note that i'm using Scala.js 1.2, Scala 2.13.3 and libraryDependencies += "org.lrng.binding" %%% "html" % "latest.release" unfortunately, can't provide scalafiddle since it doesn't support Scala 2.13, instead I created a replica project here- https://www.dropbox.com/s/i9dpsa9pz0lejtj/bindingreplica.tar.gz?dl=0

like image 200
Roman Avatar asked Sep 28 '20 13:09

Roman


1 Answers

You can use length for this.

<div>{data.length.bind.toString}</div>
like image 50
lmars Avatar answered Oct 10 '22 17:10

lmars