Closed atacan closed 1 year ago
Hey @atacan!
Thanks for the PR!
I took the liberty to fix the test that wasn't really asserting anything because I think that the task was cancelled before reaching the assertion. I also fixed ephemeral
behavior to match UserDefault
's one.
I'm currently thinking if we'd need to gather/namespace all the sequences or not. I'll give it a day or two.
Hey @atacan! I slightly reworked a few implementations. If that's OK with you, we'll merge.
That's pretty cool! Great work @atacan and @tgrapperon I'll look forward to updating to the latest version when it's made available :)
I added more tests and I unified RawRepresentable
streams APIs that I missed during my initial review. I've added some unlabeled type argument (like AsyncStream
does) to help typing the streams.
We'll merge once CI is passing.
Thanks for the PR @atacan!
Thank you very much @tgrapperon !
I have a question. What is the benefit of .map { ($0 as! Int?)
over .map { ($0 as? Int)
This is more semantical than anything else. The value that comes from the erased stream is an Int?
and not an Int
. We're sure it's the right type, so we force cast.
In the other case, we try to cast the value as an Int
, and return nil
if it fails. Of course it'd fail if you would pass Int?.none
, but it also means that if for some reason some Double?.none
is produced, it will simply map to nil
too instead of crashing (this would be totally unexpected, so we don't want to recover and we want to spot this if it happens).
So in both cases you have a function (Any) -> Int?
, but one crashes if you pass anything else than an Int?
as argument, whereas the other would silently produce nil
.
In other words, it makes the code a little safer.
AsyncStream
s forUserDefaults
dependencydateValues
to discuss