Skip to content

Conversation

@oowekyala
Copy link

So there's something that I needed and I think it can be useful in the main repository. Changelog:

  • Add LiveList#flattenVals: basically this can be viewed as a transformation ObservableList<Val<T>> -> LiveList<T>, it "flattens" the Val context into the list. I guess the transformation would be functionally equivalent to _.flatMap(LiveList::wrapVal)
    • The returned list observes the changes of its individual elements and outputs them as ListChanges.
    • Example use case:
LiveList<BlogEntry> entries = ...;

// the size property is now also updated when any BlogEntry.wasReadProperty() changes value
Val<Integer> readBlogs = entries.flattenVals(BlogEntry::wasReadProperty)
                                .filter(Boolean::booleanValue)
                                .sizeProperty();
  • The implementation needed implementing a dynamic subscription function for ObservableLists, which is in fact quite useful! I think that has the potential to e.g. simplify implementation of Implement ObservableList.flatMap #53

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

Successfully merging this pull request may close these issues.

1 participant