iosswiftviper-architecture

Where have timer be in Viper architecture


Let's suppose that every 10 seconds we have to update our data. Where should we create/store timer and where will it fire associated method in VIPER architecture? Should ViewController do that and inform presenter? or Presenter should hold the timer?


Solution

  • Updating data is not something that a Presenter or a Controller should be concerned with. Presenter (as the name suggests) should only be in control of presentation and stuff. in VIPER architecture, Interactor is responsible for handling logics, and "Updating every 10 seconds" sounds like a logic to me. so the Timer should be Interactor and upon fire, should inform Presenter, then Presenter inform Controller accordingly. (If you think that's too much boiler-plate, well that's just VIPER)