Creating our own publisher in Combine

Hi,

I have a class or a struct and I would like to make my own publisher that watches a property or the class and publishes its value everytime it changes.

 

The only way I can think of is to creata a pass through subject and then call ‘send’ on it everytime the property changes (in the didSend)

 

but I have a feeling there is probably a better pattern for this that I might be missing? Is there a better way to acheive this? Is there something like  the opposite of ‘Assign’? that lets you publish changes to a property?

Powered by WPeMatico

About

You may also like...

Comments are closed.