Giter VIP home page Giter VIP logo

strongify's Introduction

Strongify

1-file µframework that gets rid of weak-strong dancing in Swift.

Basically allows you to go from this:

target.closure = { [weak self, weak other] some, arguments in 
    guard let strongSelf = self, let strongOther = other else { return }
    /// ... code
}

To this:

target.closure = strongify(weak: self, other) { strongSelf, strongOther, some, arguments in
    /// ... code
}

Read more

Installation

Swift Package Manager

Add .Package(url: "https://github.com/krzysztofzablocki/Strongify.git", majorVersion: 1) to your Package.swift file's dependencies.

CocoaPods

Add pod 'Strongify' to your Podfile.

Carthage

Add github "krzysztofzablocki/Strongify" to your Cartfile.

License

Strongify is available under the MIT license. See LICENSE for more information.

Attributions

I've used SwiftPlate to generate xcodeproj compatible with SPM, CocoaPods and Carthage.

strongify's People

Contributors

krzysztofzablocki avatar rlwimi avatar jegnux avatar mgraczkowskidigitalforms avatar tangbl93 avatar

Stargazers

Jacek Łapiński avatar Patrick Lafleur avatar Yevhen avatar hailong avatar Jans Pavlovs avatar  avatar Ostap avatar Schinckus Lionel avatar Mike Pujol avatar Phoenix avatar Thomas Angistalis avatar Andreas Link avatar  avatar  avatar László avatar David Smith avatar Mohamed Taher Mosbah avatar Suhit Patil avatar Batıkan Sosun avatar Hasan Güngör avatar Yasin ATEŞ avatar Deya Eldeen Elkhawaldeh avatar Chris avatar Nguyen Chi Cong avatar Vyacheslav Khorkov avatar ddoo avatar  avatar Kenzan Hase avatar Brandon Erbschloe avatar Bruno Gama avatar Nic avatar Pho Hale avatar 浪漫恋星空 avatar BrainCrumbz avatar Nick Pannuto avatar Tranld avatar Luciano Polit avatar George Kaimakas avatar  avatar Michal Duda avatar  avatar Andre Vinicius avatar Duy Le Ngoc avatar  avatar Takuya Ohsawa avatar SeongHo Hong avatar Bora avatar Manolis Pahlke avatar Alona Ilienko avatar Michael avatar Yajie Xue avatar Kevin.Y avatar Michil K. avatar santsai avatar Amr Salman avatar James Campbell avatar Daniel Coffman avatar Mathias Amnell avatar Zitao Xiong avatar Kangsoo Lee avatar Amadeu Andrade avatar 公子荣 avatar Rehan Ali avatar Ben Chatelain avatar Mariusz Henke avatar Varun Kapoor avatar  avatar Joan Disho avatar Aleksandr Malina avatar Martin I. Demiddel avatar Guillian Balisi avatar Vladyslav Lypskyi avatar David Lajos avatar Suwanviwatana Kananat avatar  avatar Rakhim Abdullayev avatar RavenDeng avatar  avatar 张良 avatar  avatar Ashley Coleman avatar Brooks avatar Mufakkharul Islam Nayem avatar Norton Pigozzo avatar Klein Mioke avatar Heath-Supergene avatar iBetter avatar Michal Ciurus avatar Dongdong Gao avatar Matheus Cardoso avatar HyunJoon.Park avatar Otto Schnurr avatar Maciej Królikowski avatar  avatar Melo Chale avatar Sacha DSO avatar chuanhd avatar Sasi Kiran Malladi avatar Sinisa Kolarevic avatar Vasily Popov avatar

Watchers

James Cloos avatar Richard B. avatar  avatar Valeriy Van avatar  avatar 运筹 avatar  avatar

strongify's Issues

Operator instead of a function ?

Just to continue here our twitter discussion:

What about a custom operator version:

target.closure <= (self, other, { strongSelf, strongOther, some, args in
    // ... code
})

Are any limitation from user point of view to code completion of using Strongify ?

More explicit naming

Just a random idea, wouldn't it be more explicit with something like that:

target.closure = strongify(weak: self, weak: other) { strongSelf, strongOther, some, arguments in
    /// ... code
}

First I thought about using guard but it's not possible:

target.closure = guard(weak: self, weak: other) { strongSelf, strongOther, some, arguments in
    /// ... code
}

impact on build time?

hello, can you do a benchmark on build time / indexing time, so we decided to use this or not? because I see the implementation is somewhat redundant.

Thanks.

Default return value

Hi it's possible about you create strongify with specific default value as return statement, when one of the context doesn't exist anymore?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.