Allow to start and stop the effects programmatically
Having the option to manually start and end the effects allows for more use-cases.
Right now, this is only possible by manipulating the alpha of the effects which is not ideal in terms of both user- and developer-experience.
The idea is to have a .start() and .stop() functionality for all effects. Although different implementations would be necessary for the SpriteKit and CAEmitterLayer based effects, the API has to be the same for making it a streamlined effort for developers to integrate.
I was looking to pass a Binding to start/stop the effect.
Yes, as you said, it's necessary.
That's one approach for sure @Dave181295!
So, what you always can do, is to have a @State property that's conditionally showing the respective effect.
Something in the realm of:
@State private var showingEffect = true
/// ...
if showingEffect {
ConfettiView()
}
/// ...
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
withAnimation {
showingEffect = false
}
}
}
But that would just be a workaround for now, we'll find a better way and expose that in one of the upcoming versions! If you have wishes for the functionality, feel free to add them here! :)