6 Comments
User's avatar
Tarek M. Ben Lechhab's avatar

Nice write up, thanks Natasha!

Expand full comment
Ray Rez's avatar

This still requires iOS 26, right?

I prefer using Firebase because it handles streaming and provides a proxy (needed to hide API key).

Expand full comment
NatashaTheRobot's avatar

Yes - you're right. There are other ways to accomplish this. Just wanted to show this one as an option.

Expand full comment
Ray Rez's avatar

This way of doing it that you demonstrated here is pretty clever. Thank you for sharing

Expand full comment
NatashaTheRobot's avatar

This should also work with the Firebase streaming API as long as they're streaming json.

Expand full comment
NatashaTheRobot's avatar

Sorry - can't see your other comment, but I updated the post to show that yes, this works with partial json strings as they come in!

So this partial json: {"company":"Apple Inc.","eps":1.48,"key_highlights

Will be converted to this object:

Analysis(company: Optional("Apple Inc."), quarter: nil, revenue: nil, net_income: nil, eps: Optional(1.48), revenue_growth_yoy: nil, key_highlights: nil)

Which you cannot do with Codable as it'll need to be a complete json string to decode.

Expand full comment