Swift Combine: About @Published Wrapper, things you probably didn’t know

@Published is Combine Publisher

@Publisehd is only used in class

Property with @Published is declared on ViewModel Class

@Published can be used without ObservableObject

@Published is quite similar to CurrentValueSubject

@Published vs CurrenetValueSubject

Difference between @Published and CurrentValueSubject

Difference between @Published and CurrentValueSubject

Conclusion

  • @Published is Combine Publisher
  • @Published can only be used in Class
  • @Published is quite similar to CurrentValueSubject because it can hold a value.
  • @Published doesn’t need to call send() method or access .value. When you directly change its value, it will update the value.

--

--

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

2.4K Followers

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