lngyeen / MySurveyChallenge

0 stars 0 forks source link

[Question] Thread switching in Repository and Network layer #32

Closed blyscuit closed 4 months ago

blyscuit commented 4 months ago

Issue

lngyeen commented 4 months ago

@blyscuit

  1. I checked the source code and there are a total of 4 places where this function is used:
  1. If a repository or a use case calls two network request with Publishers.merge, so it depend on which thread the each Publisher on Publishers.merge run on. For example: 1st one emit values 1-3-5 and run on main thread, 2nd one emit 2-4-6 and run on background thread so in Publishers.merge the observation code will run on main thread when it receive values 1-3-5 and on background thread when receive values 2-4-6. Therefore, to unify the observation thread for Publishers.merge, we need to use the receive(on:) for Publishers.merge.

  2. No, I believe API calls will not block the main thread.