Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SeqProperty direct API should be more immutable #440

Open
ddworak opened this issue Oct 30, 2019 · 0 comments
Open

SeqProperty direct API should be more immutable #440

ddworak opened this issue Oct 30, 2019 · 0 comments
Milestone

Comments

@ddworak
Copy link
Member

ddworak commented Oct 30, 2019

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
@ddworak ddworak added this to the 0.9.0 milestone Oct 30, 2019
@ddworak ddworak modified the milestones: 0.9.0, 1.0 Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant