Latest 0.0.8
Homepage https://github.com/beeth0ven/WeakOwner
License MIT
Platforms ios 8.0, osx 10.9, tvos 9.0, watchos 2.0, requires ARC
Authors

Build Status
Swift
CocoaPods
Carthage compatible

A better way to deal function with weak reference.

At a Glance

  • Function without return value:

    button.rx.tap
      .subscribe(onNext: weak(self) { me in me.showAlert() })
      ...

    is equivalent to:

    button.rx.tap
      .subscribe(onNext: { [weak self] in
          guard let me = self else { return }
          me.showAlert()
      })
      ...
  • Function with return value:

    let searchResults = rxText
      .flatMapLatest(weak(self, default: .empty()) { me, text in
          me.searchGitHub(text)
      })

    is equivalent to:

    let searchResults = rxText
      .flatMapLatest { [weak self] text -> Observable<[Repository]> in
          guard let me = self else { return .empty() }
          return me.searchGitHub(text)
    }

Installation

  • For iOS 8+ projects with CocoaPods:

    pod 'WeakOwner'
  • For iOS 8+ projects with Carthage:

    github "beeth0ven/WeakOwner"

License

WeakOwner is under MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "WeakOwner",
    "version": "0.0.8",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "summary": "A better way to deal with weak reference function.",
    "homepage": "https://github.com/beeth0ven/WeakOwner",
    "authors": {
        "Luo Jie": "[email protected]"
    },
    "source": {
        "git": "https://github.com/beeth0ven/WeakOwner.git",
        "tag": "0.0.8"
    },
    "source_files": "WeakOwner/Sources/*.swift",
    "requires_arc": true,
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This