Unlock This Episode
Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.
This is starting to show the power behind explicit animations. They allow you to be far more targeted in what you want to animate and how you want to animate.
It’s also worth noting that SwiftUI used to more heavily lean on implicit animations. For example, it used to be that if you ever made a change to the data source powering a
List view then those changes would automatically animate. That would cause rows to animate into place or slide away when removed. That made for a really nice demo since you could get animation basically for free, but also meant that a lot of really strong opinions were hardcoded directly in SwiftUI’s foundational components, which seems strange. However, in iOS 14 and Xcode 12 that behavior was changed so that you had to start using explicit animations in order to animate a
List view. So it appears that SwiftUI is heading more towards favoring explicit animations over implicit animations.
So, that’s the basics of SwiftUI animations. They come in two major flavors: implicit and explicit. Implicit is heavily state driven, in that whenever state changes it will automatically animate all changes to the view based on that state change. You don’t have the ability to perform animations when an event occurs, it only happens when state changes. This is why it was so hard to prevent animations when the reset button was tapped. Because that is an event and implicit animations don’t handle events well.
On the other hand, explicit animations are far more targeted and more event driven. This means that when events occur we can tell SwiftUI to animate a state change. This is why it was so easy to opt in or out of animation when the animation button was tapped.
Subscribe to Point-Free
Access this episode, plus all past and future episodes when you become a subscriber.
Already a subscriber? Log in
If you tap “cycle colors” and then immediately tap “reset” any in-flight effects will still animate the circle’s color. Add effect cancellation logic to the reducer so that the “reset” button cancels such in-flight effects.
Our application is simple in that most of the actions fed to the reducer mutate state simply. Reduce the number of explicitly-defined actions in
AppActionto use the
BindingActionform helper instead.
A word game by us, written in the Composable Architecture.
Collection: SchedulersBrandon Williams & Stephen Celis • Thursday Jun 4, 2020
We previously did a deep-dive into all things Combine schedulers. We showed what they are used for, how to use them in generic contexts, and how to write tests that make the passage of time controllable and determinstic.
There’s a lot of great material in the community covering almost every aspect of the Combine framework, but sadly Combine’s
Schedulerprotocol hasn’t gotten much attention. It’s a pretty mysterious protocol, and Apple does not provide much documentation about it, but it is incredibly powerful and can allow one to test how time flows through complex publishers.
combine-schedulersBrandon Williams & Stephen Celis • Sunday Jun 14, 2020
An open source library that provides schedulers for making Combine more testable and more versatile.