-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the Equatable requirement on components.
- Loading branch information
Showing
15 changed files
with
95 additions
and
328 deletions.
There are no files selected for viewing
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import FlexibleDiff | ||
|
||
extension Changeset { | ||
/// Retrieve the positions of all mutated items, in place or moved. The changes are filtered | ||
/// by the specified collection of pre-removal visible item indices. | ||
/// | ||
/// - parameters: | ||
/// - visibleItems: The pre-removal indices of the visible items. | ||
func positionsOfMutations<Indices: Collection>(amongVisible visibleItems: Indices) -> FlattenCollection<[[(source: Int, destination: Int)]]> where Indices.Element == Int { | ||
return [ | ||
mutations.lazy | ||
.filter(visibleItems.contains) | ||
.map { (source: $0, destination: $0) }, | ||
moves.lazy | ||
.filter { visibleItems.contains($0.source) } | ||
.map { (source: $0.source, destination: $0.destination) } | ||
].joined() | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
## Bento Component Contract | ||
Applicable to both UICollectionView and UITableView. | ||
|
||
### Components must conform to `Renderable`. | ||
`Renderable` represents a set of requirements which a component must satisfy for Bento to integrate it. | ||
|
||
### Components need not be evaluable for equation. | ||
Bento enforces no restriction in what types of properties the component can comprise of. Moreover, there are also prevalent uses of non-equatable properties, for example, user interaction callbacks. Therefore, Bento does not require any component to be evaluable for equation. | ||
|
||
### Any given ID path may be bound with any kind and instance of components at any time. | ||
Bento is designed to be very flexible in terms of component types. Users should require no extra precaution in populating their `Box`es with different permutations of ID paths and components. | ||
|
||
### Visible ID paths may be aggressively rebound. | ||
[As Bento cannot rely on component equation](#components-need-not-be-evaluable-for-equation), Bento aggressively rebinds all visible ID paths with the new component at the same ID path in any new `Box` being applied. | ||
|
||
### Components should avoid deriving animations from rebinding occurrences. | ||
[Given potential occurrences of aggressive rebinding](#visible-id-paths-may-be-aggressively-rebound), rebinding is generally not a good indiction of when animations should happen. Components might want to instead have data-driven, fine-grained animations, or rely on mechanisms like `ViewLifecycleAware`. |
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
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
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
Oops, something went wrong.