Swift Combine: CurrentValueSubject, the most useful subject of all times

What is Subject in Combine?

Core Functionalities of CurrentValueSubject

  1. Access value directly with currentValueSubject.value.
  2. Subscribe to Subject.
  3. Passing down new value with Subject.
  4. Sending completion finished with Subject.

CurrentValueSubject

CurrentValueSubject

[1] Access value directly with currentValueSubject.value.

Access Directly

[2] Subscribe to Subject

Subscribe to Subject

[3] Passing down new values with Subject

Passing Down

[4] Sending completion finished with Subject.

Sending completion .finished

What distinguishes CurrentValueSubject from Other Subjects?

Conclusion

  1. Access value directly with currentValueSubject.value.
  2. Subscribe to Subject.
  3. Passing down new value with Subject.
  4. Sending completion finished with Subject.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
KD Knowledge Diet

KD Knowledge Diet

Software Engineer, Mobile Developer living in Seoul. I hate people using difficult words. Why not using simple words? Keep It Simple Stupid!