This is a technique suggested to me by Jordan Gustafson (@minnesota_gus) on how to make a CurrentValueSubject that doesn’t require an initial value. This should probably be developed into an actual type which conforms to
Subject, but I haven’t figured that out yet.
This will produce the following output:
[Example] sending value: 1
[Example] sending value: 2
As you can see, the first subscription did not receive a value until the first time
doSomething() was called. Conversely, the second subscription—which was added after the first value had been sent—received a value immediately. Both subscriptions receive all values thereafter.