Denis Chaschin
1 min readMar 1, 2020

--

The reason here is that in your example, `ModalLink` owns the modal view state (opened/closed) which means once it is recreated — the modal view would close.

To overcome this, we have separate objects:

  1. `ModalPresenter` — owns the state and presents/hides the modal. This object should live in the place that is not updated often.
  2. `ModalLink` — a button that can send its events to the modal presenter through the environment. It is safe to recreate or update button as often as it is needed.

--

--

Denis Chaschin
Denis Chaschin

Written by Denis Chaschin

Creating iOS apps. Living in Sydney, originally from Saint-Petersburg

No responses yet