-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Merge thoughtbot/Bindings as a subtree of CombineViewModel #8
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The standard library includes this curious operator declaration: infix operator ~> : DefaultPrecedence However there are no protocols are free functions that provide any definition or hint at its intended semantics. In light of this, it makes a lot of sense for both operators to exist in the same precedence group. DefaultPrecedence is at a slightly higher precedence than BindingPrecedence was, now binding more tightly than the ternary operator. This feels reasonable, as now it's possible to, e.g., switch between two different binding statements in a ternary expression.
`Cancellable.store(in:)` is overloaded for two kinds of collection: either any `RangeReplaceableCollection`, or `Set`. Given that `Set` is more specific, prefer it over `Array`.
Extracts a `_getBox()` helper method that initialises an empty `Subscriptions` box if necessary and then returns a reference. This is used to streamline the implementation of _read/set/_modify accessors. These are also marked inlinable.
Use _read/set/_modify for associated-object-based subscriptions
Bindings provides the `BindingOwner` protocol, which implicitly extends all conformers with a `Subscriptions` collection. This makes it possible, in a generic context, to scope a given binding to the lifetime of the object that owns the binding. By inheriting `ViewModelObserver` from `BindingOwner`, all observers gain the benefit of this automatic collection of subscriptions. As a side effect, we can update all our examples to remove the explicit declaration of a `subscriptions` property.
sharplet
force-pushed
the
merge-bindings
branch
from
August 24, 2020 22:04
efd4423
to
124a8a5
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I propose we merge https://github.com/thoughtbot/Bindings directly into CombineViewModel, merging their histories. The benefits to reusing the
BindingOwner
protocol should be clearly illustrated in #9.Why combine the histories of these two repositories instead of simply depending on Bindings?
You may be wondering, "What about SwiftUI?" I feel pretty confident it will be the future of app development on Apple platforms, but it's not there yet. However, one of my goals in building this package atop Combine's
ObservableObject
protocol is that view models you develop with CombineViewModel should slot directly into SwiftUI apps, potentially without even modifying the view model code. I'd love for this package to become a bridge to introducing SwiftUI in existing UIKit and AppKit codebases, be leveraging the same tools at the data and controller (a.k.a. view model) layers.Bindings
andUIKitBindings
targets.ViewModelObserver
to inherit from theBindingOwner
protocol.Merge the example apps together.(Bindings doesn't have an example app!)Deprecate Bindings and direct users to CombineViewModel.(see Deprecate Bindings and direct users to CombineViewModel #11)