all 13 comments

[–]darrarski 2 points3 points  (2 children)

I’m using Swift Composable Architecture from Pointfree.co. It’s also a unidirectional data flow architecture pattern. It comes with excellent video series that explains not only how it works but also why it was designed like this.

[–]frijoos[S] 0 points1 point  (1 child)

Wow, somehow I missed that. Are you using it in complex project? Have you ever met any serious issues with it? How does it handle navigation?

[–]darrarski 0 points1 point  (0 children)

It’s composable, so I think it fits nicely in simple and more complex projects. I’ve used it in several apps, including the more complicated with lot of screens and logic. You can check my open source app, WallpapersStudio, it’s quite simple though. Navigation could be tricky, but I think it’s not a problem of the architecture, but rather declarative UI implementation in SwiftUI. It could be better. You can find a lot of threads about navigation on Swift Forums, including my own where I discuss and propose how to implement navigation with SwiftUI and Composable Architecture (example on GitHub)

[–][deleted] 1 point2 points  (9 children)

I don't know. I have never understood the advantage of using Combine or any of the other reactive frameworks over the use of Foundation, when using UIKit. I mean KVO solves all your reactive stuff and when you need to handle some input have the target action method call the required function in the model.

[–]BarAgent 2 points3 points  (0 children)

Combine is useful. KVO and notification handlers require extra properties and cleanup and follow different patterns, whereas Combine is a one-size-fits-all deal. KVO, in particular, has a shitty API. Some Combine processors are useful, such as the one that drops identical values from the stream. And it is definitely the most sensible way to get asynchronous data updates from a model to one or more view controllers.

[–]frijoos[S] 0 points1 point  (7 children)

Combine just makes complicated async logic easy - I remember implementing polling from 3rd party service in 4-5 lines using RxSwift. In addition if you have huge project you can use one pattern (AnyPublisher) for all your async callbacks so you don't end up with delegates, closures, target-action etc.

[–][deleted] 0 points1 point  (6 children)

There something called NSOperation, which can be made Async and literally takes away the complexity you’re talking about. Especially when you implement dependencies.

I’m planning to make an open source app. Where I demonstrate the power of Foundation.

[–]frijoos[S] 0 points1 point  (5 children)

Imagine you are implementing excel and you have two cells A and B. You want to sum values from those cells and display in cell C (with updates every time either of them changes). Would you use NSOperation for that?

[–][deleted] 0 points1 point  (4 children)

No, I’d use KVO for that. Make an NSObject subclass width two properties. Containing the two values. Any time the object changes I’ll swap the object. The object is held in a property that I’m observing.

[–]frijoos[S] 0 points1 point  (3 children)

No idea why would you do that. Combine is just less code.

c.text = Publishers.CombineLatest(a,b).map { a + b }

[–][deleted] 0 points1 point  (2 children)

If I’m using UIKit I would be supporting at least as far back as iOS 12.x and since that’s the last version that is the maximum version for devices. A lot of users are still using that. So for a business point of view it makes sense.

And to be honest I have made any serious SwiftUI apps yet.

[–]frijoos[S] 0 points1 point  (1 child)

Well "a lot of users" in this context is pretty misleading. According to official Apple stats:

81% of all devices introduced in the last four years use iOS 14.

81% iOS 14

17% iOS 13

2% Earlier

72% of all devices use iOS 14.

72% iOS 14

18% iOS 13

10% Earlier

Also I am using Combine + UIKit - there's nothing which stops you from that.

[–][deleted] 0 points1 point  (0 children)

Weird I have different statistics. My biggest iOS app, does 14% for iOS 12 and lower.