Constraid v7.1.0
Constraid v7.1.0 is available and includes a new API.
API Layers
In this release we provide a higher level API based on the Proxy pattern to make things nicer. Constraid effectively provides two public API layers now.
- high level Proxy pattern based API
- low level function API
Don't worry this new API layer is strictly a convenience API layer. So this release is 100% backwards compatible and all the low level function API will continue to work. In fact the new convenience API layer is actually built on top of the lower level function API.
Syntactic Sugar & Chaining
This new API layer is all about providing a nicer, more convenient API. It does so by utilizing the Proxy pattern to support chaining. In turn providing a much nicer API.
The original API layer is effectively a set of functions that create and return Autolayout Constraint Collections which can be combined together to make larger constraint collections. An example of this is as follows:
(flush(childView, withVerticalEdgesOf: parentView) +
center(childView, verticallyWithin: parentView)).activate()
Well, dealing with the +
operator and the parens is no longer necessary. As the above can now be implemented using the Proxy pattern API as follows:
childView.constraid
.flush(withVerticalEdgesOf: parentView)
.center(verticallyWithin: parentView)
.activate()
I hope you can agree this is an easier to read API style and it still provides all the important features and functionality of the lower level API.
But don't worry. If we somehow accidentally missed something you can always fall back to using the lower level function API we all used before.