Imagine a registration flow with a few steps (screens) and each of them fils some information about a user. Finally, you have to construct the user by the data from the previous steps... how?
There're many solutions to achieve it - using optional properties and just pass an object over the screens; maybe create a dictionary with filed data and so on.
But I really adore this solution by utilizing KeyPath's, Generics and subscripts to create a partial object. Of course, in no way without downsides, but they're so minor and it doesn't prevent to use it!
p.s. Recently I already posted the similar article, but this one looks really great with more details about a realization.
https://josephduffy.co.uk/partial-in-swift
#swift #keypath
There're many solutions to achieve it - using optional properties and just pass an object over the screens; maybe create a dictionary with filed data and so on.
But I really adore this solution by utilizing KeyPath's, Generics and subscripts to create a partial object. Of course, in no way without downsides, but they're so minor and it doesn't prevent to use it!
p.s. Recently I already posted the similar article, but this one looks really great with more details about a realization.
https://josephduffy.co.uk/partial-in-swift
#swift #keypath