@Published Property Wrapper

The @Published property wrapper allows any given property to be a publisher and emit its changed values. In the example below the calendarYear property is a publisher and prefixing the property with a $ allows us to subscribe to it or perform publisher operations. As a publisher, combine operators can now be performed on it, here we are using the sink operator to get changed values and print to the console. In an actual app this value can be bind to a UI element using the assign operator.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s