MihaelIsaev / UIKitPlus

🏰 Declarative UIKit with LivePreview for iOS9+ (best alternative to SwiftUI)
MIT License
596 stars 35 forks source link

Possible to Chain `@UState` properties? #28

Closed markst closed 2 years ago

markst commented 2 years ago

Wondering if it's possible to chain UState properties.

For instance if I have a view model with a UState:

struct ShowDetailViewModel {
  @UState var tracklist: NSAttributedString = .init(string: "")
class ShowDetailView: UView {
  @UState var viewModel: ShowDetailViewModel?
UText($viewModel.$tracklist)
MihaelIsaev commented 2 years ago

@markst yes It is possible this way

UText($viewModel.and($tracklist).map { left, right in
    return "\(left)\(right)"
})