rundfunk47 / stinsen

Coordinators in SwiftUI. Simple, powerful and elegant.
MIT License
926 stars 98 forks source link

Fix: RouterObject retrieve is nil even in the case when there is a not nil router available in the store #80

Closed Kondamon closed 2 years ago

Kondamon commented 2 years ago

RouterStore stores all routers in the wrapper WeakRef<AnyObject>. Since AnyObject is not released, the array of the store gets bigger and bigger and holds more and more nil references (screenshot from example app):

Screenshot 2022-07-17 at 10 42 28

As a consequence, also the retrieve function returns routers that are nil even in the case when there is a not nil router (of the same type) available in the store.

This pull requests cleans up all nil routers when a new router is stored and retrieves not nil routers when there are retrieved.

rundfunk47 commented 2 years ago

Awesome! 👍🏽