Haha, these guys are incredible. They defend their nonsense code at any cost, even when the alternative is a million times better and a proven, documented pattern from React 😂
@pointfreeco@malhal No need to be cynical. Claude is just a tool. As usual, your examples are nonsense. You are using SwiftUI wrong. Shame what happened to people who had big potential in 2018. Claude and I will respond soon.
@SwiftUIMaster@pointfreeco I agree theirs is an anti-pattern but your attempt has a memory leak breaking the rule we are not supposed to init objects inside body like you do with Model here:
var body: some View {
MemoView(Model(input: input) ...
Nice @pointfreeco that you noted: solution is not full for every problem. But most of your almost cult-like audience thinks it is. I sent my tweet to the wrong address then and I apologise 🙏
It's not an anti-pattern. You both just seem to think that when we provide a tool we are saying it is the full solution to every problem that anyone can ever think of.
But all we are saying is that this tool solves a certain kind of problem well. In particular, the type of problem where a child feature is presented with some dynamic data. If that dynamic data can change and should propagate to the child, you can take some steps to make that happen. But very often that is not even needed.
And in the case of Lazar's solution, it does not leave the possibility that the user does not want their model to be completely blown away anytime the input changes. That would cause all async work to be cancelled and discarded. It may be the case that the user simply wants the input to be updated in the model, but keep the same model around.
I hope you can see there is nuance to all of these problems and that there is no "one size fits all" solution.
@malhal@pointfreeco Dear Malcolm, there is no leak, cached object will be discareded when stateful MemoView is discarded from the graph. I can prove with a test.
I generally agree about body-init and suggested an unpopular alternative, my fav: lift creation on the mutation!
@ardit33@ronchumaceiro@twannl@observable Whoever uses MVVM or any MV🍆 pattern in SwiftUI today, 7 years after release, should just change proffession. Not even AI is capable to cleanup this mess since >90% of “devs” are just cargoculting and need to be laid off. So dissapointed in the author above.
@krzyzanowskim@seanallen_dev@AlgoCloudz well yes native does mean better automatically, by default! and vibe coded does not have to be unstructured, two platforms can be perfectly vibe coded if yoy share the feature spec
Point-Free’s whole model runs on complexity bias. Long episodes, deep dives, formal language, and a beginner comes out thinking “wow, SwiftUI is really this hard” instead of “wait, why did we need any of this?”
No. You don’t need it!
Compare to SwiftUI’s LazyState (wrapped in a macro by us), where we get to drop all the Optional dancing, potentially buggy “onAppear” logic, and generally write things as succinctly as possible:
@pointfreeco Two principles in SwiftUI: data access as dependency, single source of truth. Entire framework in 2 seconds. Timeless. ObservableObject came and went, they didn’t move. People break them, you sugarcoat it so they keep breaking them. Disservice to the community. Said code’s coming
@Nanjialonguazt@pointfreeco Exactly. And the answer to an ownership problem is fixing the owner, not a macro that lets the wrong owner keep the state. LazyState skips the decision you’re saying is the hard part.
@pointfreeco Data flow being 7 years old isn’t a weakness, it’s what foundational means. Everything since sits on top of it. If your solution needs the foundation to be outdated that’s the solution’s problem. You keep reinventing the wheel except your wheel isn’t round it’s just sugarcoated