-
Notifications
You must be signed in to change notification settings - Fork 0
Load and persist block editor from actual data #987
Comments
Here's my current plan.
We could play changes from one to the other. But I have a simpler idea in mind...
What we get out of this:
|
Upon further reflection:
The most efficient thing for us to do is update model and controller together. So I think this still leaves us needing a second store class for UIKit. Ideas:
|
Attempting a stateless implementation with
I wrote a custom diff that diffed list by ID and updated cells by model hash. Findings:
Additional challenges with stateless approach to UICollectionView:
|
Promising: https://github.com/ra1028/DifferenceKit. It implements what we want — ID based collection diffing inferring insertions, removes, and moves by identifier, and inferring changes by equatable. However, it reloads, rather than reconfigures changed items. https://github.com/ra1028/DifferenceKit/blob/02ca1968b10305d4d6771f4005a7ce2c507a8539/Sources/Extensions/UIKitExtension.swift#L105 We need updated items to reconfigure rather than reload so that the cell is not discarded, losing focus. Using this would require us to implement our own |
Fixes #987. Depends on subconsciousnetwork/ObservableStore#43 This PR implements basic loading and saving of real data from database, including blocks and related notes. I've kept the scope to *just* saving and loading, and there is more work to be done wrt transcludes and loading states. ## Approach - New changes to ObservableStore allow creating custom Update types for models. subconsciousnetwork/ObservableStore#43 - Also introduces an `updates` publisher on stores - Custom update type lets us include a change description along with state changes, supplying extra information that the ViewController might need to perform these changes. - Root UIViewController subscribes to `updates` publisher and performs updates to controller based on state transactions. - ObservableStore instance is stored as a `@StateObject` on the enclosing SwiftUIView and passed down as an `@ObservedObject` to the UIViewControllerRepresentable. The result is that we can share the same store between SwiftUI and UIKit land, as well as the same environment and side effects management.
Part of #214
The text was updated successfully, but these errors were encountered: