Comments (3)
Glad you enjoyed! @mbrandonw's on a flight somewhere over the ocean right now and may have his own thoughts, but I figured I could answer some of this for now.
Was this on your radar when you made the episode?
Virtual DOM ("virtual view hierarchy"? 🤔) and general Elm/incremental stuff has been on our radar for awhile now, but unfortunately fell out of the scope of this episode. We wanted to focus on showing plain old function composition in a practical "you can do this in your code today" kind of way (assuming you're allowed to introduce an operator to your code base—more on that in a future ep).
Do you think the approach you outlined has other advantages over this?
Mainly:
- That lack of friction: with a single function composition operation you're good-to-go.
- Avoiding the cost of distancing yourself too far from UIKit. It's probably easier to convince a team to use function composition with UIKit than jump ship for an entirely different model, where you maintain the interpreter or tie yourself to another third party.
- Although we love the testable benefits of the virtual DOM approach (you can get really great, low-cost snapshot test coverage of the hierarchical state of an entire screen by passing a "current state" to the DOM-producing function), what's nice about testing with actual view objects is you can get high-fidelity screenshot test coverage, and you can build playgrounds that act as living style guides!
Trade-offs! We'll be diving a bit deeper into composable view styling in an upcoming ep, and we'll definitely continue to explore wilder territory in the future!
Do you have any general thoughts on it?
Your example above is interesting and made me curious as to what it would look like with protocol composition! The final tagless approach might be fun to explore here and would allow us to avoid those downsides of inheritance or "object composition" using a view
property. E.g.:
protocol View { … }
protocol Button: View { … }
Then we could have an interpreter for producing a UIKit
hierarchy, and a separate interpreter for testing the hierarchy alone.
from episode-code-samples.
I should note that @bkase and @chriseidhof have been exploring this stuff a lot lately! Brandon Kase gave the view hierarchy example in his talk at dotSwift, and they've shown other examples of final tagless on Swift Talk. I'm looking forward to the community continuing to explore!
from episode-code-samples.
Your example above is interesting and made me curious as to what it would look like with protocol composition! The final tagless approach might be fun to explore here and would allow us to avoid those downsides of inheritance or "object composition" using a view property
This is one of those examples that makes me wonder what it'd be like to live in a language like Elm that uses structural typing. 🤔
from episode-code-samples.
Related Issues (20)
- @FocusState not working with new @BindableState API HOT 5
- UIApplication.shared.windows deprecated in iOS 15 HOT 1
- 0167 Navigation is weird on iPad HOT 1
- Please fix the error Episode #76 ~ HOT 2
- [0171-modularization-pt1] Setting Up HOT 3
- modularization folders architecture HOT 1
- Missing episode 187: URL Route? HOT 1
- Cannot convert value of type - Examples will not compile using Xcode 13.3 HOT 2
- Request: Re-Record Episode 100 to 103 and Update Source Code HOT 3
- Episode 196: Runtime warning work only in half of the cases HOT 1
- minor bug in episode 198 sample HOT 1
- Code sample for episode 220 is missing HOT 1
- Strange navigation on episode 220 HOT 1
- Episode 2 -> Fish playground -> Ambiguous use of 'init(utf8String:)'
- Episode 0228 - Composable Navigation: Destinations sample code not found HOT 1
- navigationDestination not triggered HOT 3
- Modern SwiftUI: Standups App HOT 1
- Episode 241 code not published HOT 2
- Episode 109 sheet show twice when item name changed HOT 1
- Typo in Navigation Example code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from episode-code-samples.