nalexn / clean-architecture-swiftui

SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why does the '.onReceive(routingUpdate)' perform twice?

GeoffreyChen777 opened this issue · comments

Hi, thanks for your work!

I'm learning your architecture and I found that:

.onReceive(routingUpdate) {
            print("update")  \\ added by me.
            self.routingState = $0 }

the print will be performed twice. Can you explain the reason?

Please forgive me for this simple question, because I am a newbie of swift :)

Hey @GeoffreyChen777

This phenomenon is explained in the section Phantom state updates of this article. Let me know if you have follow up questions!