Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7093779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:28:55+00:00 2026-05-28T08:28:55+00:00

In my application I have use some data ValueCell (something like 20) and I

  • 0

In my application I have use some “data” ValueCell (something like 20) and I would like to create a ValueCell which would be used to detect if any of my “data” ValueCell was updated . So I would like this cell to change whenever one of the other cells are changed.

Here is a simple code example

class StringFilter {

  val referenceList = "foo"::"bar"::"scala"::"lift"::Nil

  val length = ValueCell[Int](3)
  val content = ValueCell[String]("")

  //Here I put some functions to update length or prefix on my webpage
  def filter(s:String):Boolean = (s.length==length.get)&&(s.contains(content.get))

  val changed =ValueCell[???](???)
  val results= changed.lift(referenceList.filter)
}

What should I put instead of ???? I am also open to solutions which are not using ValueCells, even if I will in the end need some cells because I have to use WiringUI.

Edit: lengthand contentdon’t need to be cells but they need to be settable

Edit: After some more research I came to an idea: implement a case class like SeqCellbut which would not take a type for the Cells in parameter, and for an arbitrary number of cells. Is it possible?
Here is the implementation of SeqCell:

final case class SeqCell[T](cells: Cell[T]*) extends Cell[Seq[T]] {

  cells.foreach(_.addDependent(this))

  /**
  * The cell's value and most recent change time
  */
  def currentValue: (Seq[T], Long) = {
    val tcv = cells.map(_.currentValue)
    tcv.map(_._1) -> tcv.foldLeft(0L)((max, c) => if (max > c._2) max else c._2)
  }

  /**
   * If the predicate cell changes, the Dependent will be notified
   */
  def predicateChanged(which: Cell[_]): Unit = notifyDependents()
}

Edit: In scala Cellis not covariant, so it seems like I won’t be able to make a SeqCell out of my multiple typed cells. I would really appreciate a global solution for an arbitrary number of cells.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:28:56+00:00Added an answer on May 28, 2026 at 8:28 am

    Check out FuncCell. It’s just another cell that will determine its value as a function of one or more other cells. The link I gave is the companion object which has apply methods for 1-5 cells, corresponding to the existing FuncCell1 .. FuncCell5 implementations. When one of those cells changes value, the FuncCell will update its own value- you would then hook up the WiringUI with your FuncCell.

    Please forgive any syntax errors, I don’t have an IDE open to check myself…

    val changed: Cell[List[String]] = FuncCell(length, content){(len,con) =>
      def filter(s: String) = (s.length == len) && (s.contains(con))
      referenceList.filter(filter _)
    }
    

    If that’s right, then changed is now a Cell whose value will reflect the result of calling referenceList.filter


    In response to your edit regarding the SeqCell, I can think of two solutions:

    1) Use Any as the type parameter in the SeqCell

    val cell1: ValueCell[Int] = ...
    val cell2: ValueCell[String] = ...
    val cell3: ValueCell[Stuff] = ...
    ...
    val combined: SeqCell[Any] = SeqCell(cell1, cell2, cell3, ...)
    val results = FuncCell(combined){ seq: Seq[Any] => ... }
    

    2) Combine the intermediate cells into tuples so that you can use the existing FuncCell implementations.

    val intermediate1: Cell[(Int,String)] = 
      FuncCell(cell1,cell2){(a:Int, b:String) => a -> b}
    val results = 
      FuncCell(intermediate1, cell3){(i: (Int, String), s: Stuff) => ...}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application has some data which I would like to keep secure. I have
I have an application which gets some data from a remote database. I use
I have a simple broadcast receiver which receives some data which I would like
I have C# application that makes use of some C libaries(which I have written
I have a console application which screen scrapes some data, and now I need
I'm writing an API which is used to receive some data from another application.
I have an application which is making use of the RSACryptoServiceProvider to decrypt some
I have a CLI application, which is digging some data, in case of need,
I have a application, which generate image dynamically (based on some data input) on
In my application I have some table data that looks like this: <table> <tr>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.