Skip to content

SeqProperty direct API should be more immutable #440

Open
@ddworak

Description

@ddworak

SeqProperties based on immutable models usually return immutable collections:

model.subProp(_.vector).get //Vector[Int]

but direct usage is not quite as good:

SeqProperty(2,1,3).get //scala.collection.Seq[Int]

The choice of base Seq type was beneficial in terms of perfomance (as we sometimes avoid copying the collection), but proves to problematic, especially in Scala 2.13, where Seq aliases immutable.Seq. This introduces compatibility issues e.g. with Scalatags, which only accept immutable collections. Therefore, after 1:1 migration of our codebase for 2.13 (#434), we had to introduce .toSeq calls in some usages:

produce(p)(s => s.toSeq.render)

This particular issue was patched by explicit copying, but it's not a comprehensive solution, as ReadableSeqProperty[A] <: ReadableProperty[scala.collection.Seq[A], which introduces base Seq type to multiple API methods.

Proposed acceptance criteria:

  • only allow immutable sequences in SeqProperties (remove io.udash.properties.PropertyCreator#materializeBSeq)
  • ensure public API of SeqProperty is ISeq-based (especially .get, .listen etc.)
  • ensure consistency with above for .subSeq, .roSubSeq
  • use a thin wrapper / copy-on-write to avoid copying in all cases. This will also benefit the performance for past cases where an immutable collection was used as a model subsequence.
  • performance should be on-par with 0.8.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions