IntrepidPursuits / swift-wisdom

A collection of additions to the Swift Standard Library created by Intrepid Pursuits developers
MIT License
39 stars 14 forks source link

Add Rx string limiting extensions #130

Open mayasaxena opened 7 years ago

mayasaxena commented 7 years ago
tzm41 commented 7 years ago

Can it be made into a ControlProperty<String>, something similar to the implementation of orEmpty, so that it is available for bidirectional binding? I've made this:

extension ControlPropertyType where E == String {
    public var stripReturns: ControlProperty<String> {
        let values: Observable<String> = asObservable().map { $0.replacingOccurrences(of: "\n", with: "") }
        let valueSink: AnyObserver<String> = mapObserver { $0 }
        return ControlProperty<String>(values: values, valueSink: valueSink)
    }
}

so that it could be used like this:

titleField.textView.rx.text.orEmpty.stripReturns <-> viewModel.opportunityTitle >>> rx_disposeBag
ghost commented 6 years ago
52 Errors
:no_entry_sign: Array+Utilities.swift#L125 - SwiftWisdom/Core/StandardLibrary/Array/Array+Utilities.swift#L125: unexpected version number in ‘available’ attribute for non-specific platform ‘*’
@available(*, deprecated: 0.7.11, message: "Use `ip_safely` instead.")
:no_entry_sign: CellConfiguring.swift#L34 - SwiftWisdom/Core/UIKit/CellConfiguring.swift#L34: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_registerCell<T>(_: T.Type, identifier: String = T.ip_identifier) where T: UICollectionViewCell {
:no_entry_sign: CellConfiguring.swift#L42 - SwiftWisdom/Core/UIKit/CellConfiguring.swift#L42: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_registerHeader<T>(_: T.Type, identifier: String = T.ip_identifier) where T: UICollectionReusableView {
:no_entry_sign: CellConfiguring.swift#L46 - SwiftWisdom/Core/UIKit/CellConfiguring.swift#L46: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_registerFooter<T>(_: T.Type, identifier: String = T.ip_identifier) where T: UICollectionReusableView {
:no_entry_sign: CellConfiguring.swift#L50 - SwiftWisdom/Core/UIKit/CellConfiguring.swift#L50: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_registerSupplementary<T>(_: T.Type, kind: String, identifier: String = T.ip_identifier) where T: UICollectionReusableView {
:no_entry_sign: CellConfiguring.swift#L61 - SwiftWisdom/Core/UIKit/CellConfiguring.swift#L61: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_dequeueCell<T>(_ indexPath: IndexPath, identifier: String = T.ip_identifier) -> T where T: UICollectionViewCell {
:no_entry_sign: CellConfiguring.swift#L65 - SwiftWisdom/Core/UIKit/CellConfiguring.swift#L65: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_dequeueHeader<T>(_ indexPath: IndexPath, identifier: String = T.ip_identifier) -> T where T: UICollectionReusableView {
:no_entry_sign: CellConfiguring.swift#L69 - SwiftWisdom/Core/UIKit/CellConfiguring.swift#L69: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_dequeueFooter<T>(_ indexPath: IndexPath, identifier: String = T.ip_identifier) -> T where T: UICollectionReusableView {
:no_entry_sign: CellConfiguring.swift#L73 - SwiftWisdom/Core/UIKit/CellConfiguring.swift#L73: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_dequeueSupplementary<T>(_ indexPath: IndexPath, kind: String, identifier: String = T.ip_identifier) -> T where T: UICollectionReusableView {
:no_entry_sign: CellConfiguring.swift#L85 - SwiftWisdom/Core/UIKit/CellConfiguring.swift#L85: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_registerCell<T>(_: T.Type, identifier: String = T.ip_identifier) where T: UITableViewCell {
:no_entry_sign: CellConfiguring.swift#L93 - SwiftWisdom/Core/UIKit/CellConfiguring.swift#L93: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_registerHeader<T>(_: T.Type, identifier: String = T.ip_identifier) where T: UITableViewHeaderFooterView {
:no_entry_sign: CellConfiguring.swift#L104 - SwiftWisdom/Core/UIKit/CellConfiguring.swift#L104: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_dequeueCell<T>(_ indexPath: IndexPath, identifier: String = T.ip_identifier) -> T where T: UITableViewCell {
:no_entry_sign: CellConfiguring.swift#L108 - SwiftWisdom/Core/UIKit/CellConfiguring.swift#L108: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_dequeueHeader<T>(_ section: Int, identifier: String = T.ip_identifier) -> T where T: UITableViewHeaderFooterView {
:no_entry_sign: CellConfiguring.swift#L112 - SwiftWisdom/Core/UIKit/CellConfiguring.swift#L112: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_cellForRowAtIndexPath<T>(_ indexPath: IndexPath) -> T where T: UITableViewCell {
:no_entry_sign: Data+Extensions.swift#L113 - SwiftWisdom/Core/Foundation/Data/Data+Extensions.swift#L113: invalid redeclaration of ‘subscript(ip_safely:)’
public subscript(ip_safely range: Range<Int>) -> Data? {
:no_entry_sign: Geometry.swift#L10 - SwiftWisdom/Core/Geometry/Geometry.swift#L10: ‘public’ modifier is redundant for property declared in a public extension
public var ip_radians: CGFloat {
:no_entry_sign: Geometry.swift#L16 - SwiftWisdom/Core/Geometry/Geometry.swift#L16: ‘public’ modifier is redundant for property declared in a public extension
public var ip_radians: CGFloat {
:no_entry_sign: Geometry.swift#L20 - SwiftWisdom/Core/Geometry/Geometry.swift#L20: ‘public’ modifier is redundant for property declared in a public extension
public var ip_degrees: CGFloat {
:no_entry_sign: Geometry.swift#L24 - SwiftWisdom/Core/Geometry/Geometry.swift#L24: ‘public’ modifier is redundant for property declared in a public extension
public var ip_squared: CGFloat {
:no_entry_sign: Geometry.swift#L29 - SwiftWisdom/Core/Geometry/Geometry.swift#L29: ‘public’ modifier is redundant for property declared in a public extension
public var ip_complementOfPercentage: CGFloat {
:no_entry_sign: Geometry.swift#L35 - SwiftWisdom/Core/Geometry/Geometry.swift#L35: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_angle(to comparisonPoint: CGPoint) -> CGFloat {
:no_entry_sign: Geometry.swift#L46 - SwiftWisdom/Core/Geometry/Geometry.swift#L46: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_distance(to point: CGPoint) -> CGFloat {
:no_entry_sign: Geometry.swift#L77 - SwiftWisdom/Core/Geometry/Geometry.swift#L77: ‘public’ modifier is redundant for property declared in a public extension
public var ip_width: CGFloat {
:no_entry_sign: Geometry.swift#L86 - SwiftWisdom/Core/Geometry/Geometry.swift#L86: ‘public’ modifier is redundant for property declared in a public extension
public var ip_halfWidth: CGFloat {
:no_entry_sign: Geometry.swift#L95 - SwiftWisdom/Core/Geometry/Geometry.swift#L95: ‘public’ modifier is redundant for property declared in a public extension
public var ip_height: CGFloat {
:no_entry_sign: Geometry.swift#L104 - SwiftWisdom/Core/Geometry/Geometry.swift#L104: ‘public’ modifier is redundant for property declared in a public extension
public var ip_halfHeight: CGFloat {
:no_entry_sign: Geometry.swift#L113 - SwiftWisdom/Core/Geometry/Geometry.swift#L113: ‘public’ modifier is redundant for property declared in a public extension
public var ip_center: CGPoint {
:no_entry_sign: Geometry.swift#L123 - SwiftWisdom/Core/Geometry/Geometry.swift#L123: ‘public’ modifier is redundant for property declared in a public extension
public var ip_midX: CGFloat {
:no_entry_sign: Geometry.swift#L132 - SwiftWisdom/Core/Geometry/Geometry.swift#L132: ‘public’ modifier is redundant for property declared in a public extension
public var ip_midY: CGFloat {
:no_entry_sign: Geometry.swift#L141 - SwiftWisdom/Core/Geometry/Geometry.swift#L141: ‘public’ modifier is redundant for property declared in a public extension
public var ip_shortestEdge: CGFloat {
:no_entry_sign: Geometry.swift#L145 - SwiftWisdom/Core/Geometry/Geometry.swift#L145: ‘public’ modifier is redundant for property declared in a public extension
public var ip_longestEdge: CGFloat {
:no_entry_sign: PercentAnimator.swift#L20 - SwiftWisdom/Core/UIKit/PercentAnimator/PercentAnimator.swift#L20: ‘public’ modifier is redundant for static method declared in a public extension
public static func pa_percentAnimate(_ duration: TimeInterval, animation: @escaping (AnimationState) -> Void) {
:no_entry_sign: Set+Utilities.swift#L2 - SwiftWisdom/Core/StandardLibrary/Set/Set+Utilities.swift#L2: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_toArray() -> [Element] {
:no_entry_sign: Set+Utilities.swift#L7 - SwiftWisdom/Core/StandardLibrary/Set/Set+Utilities.swift#L7: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_passes(test: (Element) -> Bool) -> Bool {
:no_entry_sign: Set+Utilities.swift#L16 - SwiftWisdom/Core/StandardLibrary/Set/Set+Utilities.swift#L16: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_filter(_ include: (Element) -> Bool) -> Set<Element> {
:no_entry_sign: String+Indexing.swift#L12 - SwiftWisdom/Core/StandardLibrary/String/String+Indexing.swift#L12: invalid redeclaration of ‘subscript(_:)’
public subscript(range: CountableRange<Int>) -> String {
:no_entry_sign: UIColor+Hex.swift#L12 - SwiftWisdom/Core/UIKit/UIColor+Hex.swift#L12: ‘public’ modifier is redundant for initializer declared in a public extension
public convenience init(ip_hex hex: String) {
:no_entry_sign: UIView+GetConstraints.swift#L17 - SwiftWisdom/Core/UIKit/UIView+GetConstraints.swift#L17: ‘public’ modifier is redundant for property declared in a public extension
public var ip_widthConstraint: NSLayoutConstraint? {
:no_entry_sign: UIView+GetConstraints.swift#L22 - SwiftWisdom/Core/UIKit/UIView+GetConstraints.swift#L22: ‘public’ modifier is redundant for property declared in a public extension
public var ip_heightConstraint: NSLayoutConstraint? {
:no_entry_sign: UIView+GetConstraints.swift#L27 - SwiftWisdom/Core/UIKit/UIView+GetConstraints.swift#L27: ‘public’ modifier is redundant for property declared in a public extension
public var ip_topConstraint: NSLayoutConstraint? {
:no_entry_sign: UIView+GetConstraints.swift#L32 - SwiftWisdom/Core/UIKit/UIView+GetConstraints.swift#L32: ‘public’ modifier is redundant for property declared in a public extension
public var ip_bottomConstraint: NSLayoutConstraint? {
:no_entry_sign: UIView+GetConstraints.swift#L37 - SwiftWisdom/Core/UIKit/UIView+GetConstraints.swift#L37: ‘public’ modifier is redundant for property declared in a public extension
public var ip_leadingConstraint: NSLayoutConstraint? {
:no_entry_sign: UIView+GetConstraints.swift#L42 - SwiftWisdom/Core/UIKit/UIView+GetConstraints.swift#L42: ‘public’ modifier is redundant for property declared in a public extension
public var ip_trailingConstraint: NSLayoutConstraint? {
:no_entry_sign: UIView+GetConstraints.swift#L47 - SwiftWisdom/Core/UIKit/UIView+GetConstraints.swift#L47: ‘public’ modifier is redundant for property declared in a public extension
public var ip_centerXConstraint: NSLayoutConstraint? {
:no_entry_sign: UIView+GetConstraints.swift#L52 - SwiftWisdom/Core/UIKit/UIView+GetConstraints.swift#L52: ‘public’ modifier is redundant for property declared in a public extension
public var ip_centerYConstraint: NSLayoutConstraint? {
:no_entry_sign: UIView+GetConstraints.swift#L57 - SwiftWisdom/Core/UIKit/UIView+GetConstraints.swift#L57: ‘public’ modifier is redundant for property declared in a public extension
public var ip_aspectRatioConstraint: NSLayoutConstraint? {
:no_entry_sign: UIView+GetConstraints.swift#L71 - SwiftWisdom/Core/UIKit/UIView+GetConstraints.swift#L71: ‘public’ modifier is redundant for instance method declared in a public extension
public func ip_constraintForAttribute(_ attribute: NSLayoutAttribute, onView: UIView? = nil, toView: UIView? = nil, viewAttribute: NSLayoutAttribute? = nil) -> NSLayoutConstraint? {
:no_entry_sign: UIView+Nib.swift#L12 - SwiftWisdom/Core/UIKit/UIView+Nib.swift#L12: ‘public’ modifier is redundant for class method declared in a public extension
public class func ip_fromNib(_ nibNameOrNil: String? = nil) -> Self {
:no_entry_sign: UIView+Nib.swift#L16 - SwiftWisdom/Core/UIKit/UIView+Nib.swift#L16: ‘public’ modifier is redundant for class method declared in a public extension
public class func ip_fromNib<T: UIView>(_ nibNameOrNil: String? = nil, type: T.Type) -> T {
:no_entry_sign: UIView+Nib.swift#L21 - SwiftWisdom/Core/UIKit/UIView+Nib.swift#L21: ‘public’ modifier is redundant for class method declared in a public extension
public class func ip_fromNib<T: UIView>(_ nibNameOrNil: String? = nil, type: T.Type) -> T? {
:no_entry_sign: UIView+Nib.swift#L39 - SwiftWisdom/Core/UIKit/UIView+Nib.swift#L39: ‘public’ modifier is redundant for class property declared in a public extension
public class var ip_nibName: String {
:no_entry_sign: UIView+Nib.swift#L43 - SwiftWisdom/Core/UIKit/UIView+Nib.swift#L43: ‘public’ modifier is redundant for class property declared in a public extension
public class var ip_nib: UINib? {

Generated by :no_entry_sign: Danger

paulrolfe commented 5 years ago

@mayasaxena Do you still want this in? Or would you like us to close this pull request?

mayasaxena commented 5 years ago

@paulrolfe If we still think it's useful I can update and merge

paulrolfe commented 5 years ago

@mayasaxena That would be great, please do! Thanks