RResultBuilders
RResultBuilder
is DSL library based on Result Builder
Features
- Supports
- DSL way defining attributed string
- Building attributed strings is type safe
- DSL way of constructing ActionSheet, AlertController
- Swift 5.4 compatible
- Supports control statements(including optional checking) within DSL body builder
- Reduces boilerplate code
- Fully tested code
- Distribution with Swift Package Manager and CocoaPods
Requirements
- iOS 11.0+
- macOS 10.11+
- watchOS 4.0+
- Xcode 12.5+
Installation
CocoaPods
You can use CocoaPods to install RResultBuilders
by adding it to your Podfile
:
Swift Package Manager
Just add this dependency in Package.swift
Open your project in Xcode 11, navigate to Menu -> Swift Packages -> Add Package Dependency and enter
NSAttributedString
Following components that helps in building attributed string in easy way
- RText: This component used to construct attributed text from given string
- RLink: This component used to construct link in attributed text
- RImageAttachment: This component used to construct image attachment in attributed text
- Miscelleneaous
- REmpty: Just empty component
- RSpace: This component used to insert space and default is one space
- RLineBreak: This component used to insert new line and default is one line break
Regular
Control statements
If..else
switch..case
for..in loop
UIAlertController
There are dedicated actions those can be used to construct alert or action sheet
- DefaultAction: This action is default type with
UIAlertAction.Style
as default - CancelAction: This action is cancel type with
UIAlertAction.Style
as cancel - DestructiveAction: This action is destructive type with
UIAlertAction.Style
as destructive
Regular
With control statements
If..else
switch..case
for..in loop
Request
Making API call in declarative is fairly simple
DSL
Data Request
To get raw data as response
Callback handler
You can attach all possible handlers to Request but they are completely optional execept resume
Request Components
URL
URL can also be build in DSL way
Header
Supports standard HTTP headers
It also supports building Headers in DSL
HTTP Body
Custom Encodable Object
Raw Data
HTTP Method
Timeout
Decoding
You can even specify custom decoder
Also raw data can be decoded
URLRequest
It also generates raw URLRequest
Screenshot
Example
- Open and Run the project inside Example folder and find various use cases
Contribute
We welcome you for the contribution to RResultBuilders
, check the CONTRIBUTING.
If you find any issues or want to suggest your brilliant ideas please feel free to create pull request.
Meta
Distributed under the MIT license. See LICENSE for more information.