logo dotConferences

Representables in Swift

Logan Wright at dotSwift 2017

In this talk, Logan discusses the representable design pattern in Swift and how it can help library developers create more flexibility in their APIs without sacrificing control internally.

More details

Some examples of this can be found in the Vapor repository, here's a link to the ResponseRepresentable type.

This is used in Vapor so a user can return the object as they would normally without having to construct an entire request on each end point.

One thing not discussed here for time concerns is that this can also be inverted into an Initializable type, which is something that can be initialized by another type which can create some pretty interesting combinations and transformations between our models.