All Projects β†’ vincent-pradeilles β†’ Weakable Self

vincent-pradeilles / Weakable Self

Licence: mit
A Swift micro-framework to easily deal with weak references to self inside closures

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Weakable Self

Code Surfer
Rad code slides <πŸ„/>
Stars: ✭ 5,477 (+8457.81%)
Mutual labels:  syntax
Python
Python cheatsheet
Stars: ✭ 25 (-60.94%)
Mutual labels:  syntax
Catage
Node package and CLI tool to convert code into an image with syntax highlighting
Stars: ✭ 44 (-31.25%)
Mutual labels:  syntax
Sublime Markdown Extended
Top 100 Sublime Text plugin! Markdown syntax highlighter for Sublime Text, with extended support for GFM fenced code blocks, with language-specific syntax highlighting. YAML Front Matter. Works with ST2/ST3. Goes great with Assemble.
Stars: ✭ 645 (+907.81%)
Mutual labels:  syntax
Modiscript
Acche din aa gaye
Stars: ✭ 888 (+1287.5%)
Mutual labels:  syntax
Gc
Simple, zero-dependency garbage collection for C
Stars: ✭ 851 (+1229.69%)
Mutual labels:  memory-management
Proposal Pipeline Operator
A proposal for adding a useful pipe operator to JavaScript.
Stars: ✭ 5,899 (+9117.19%)
Mutual labels:  syntax
Memreduct
Lightweight real-time memory management application to monitor and clean system memory on your computer.
Stars: ✭ 1,101 (+1620.31%)
Mutual labels:  memory-management
Html5.vim
HTML5 omnicomplete and syntax
Stars: ✭ 901 (+1307.81%)
Mutual labels:  syntax
Errand Boy
A memory-conscious alternative to os.fork() and subprocess.Popen().
Stars: ✭ 34 (-46.87%)
Mutual labels:  memory-management
Phplint
πŸ› A tool that can speed up linting of php files by running several lint processes at once.
Stars: ✭ 646 (+909.38%)
Mutual labels:  syntax
Natasha
Solves basic Russian NLP tasks, API for lower level Natasha projects
Stars: ✭ 788 (+1131.25%)
Mutual labels:  syntax
Comby
A tool for structural code search and replace that supports ~every language.
Stars: ✭ 912 (+1325%)
Mutual labels:  syntax
Articles Translator
πŸ“šTranslate the distinct technical blogs. Please star or watch. Welcome to join me.
Stars: ✭ 606 (+846.88%)
Mutual labels:  memory-management
Nord Highlightjs
An arctic, north-bluish clean and elegant highlight.js theme.
Stars: ✭ 49 (-23.44%)
Mutual labels:  syntax
Redis Memory Analyzer
Redis memory profiler to find the RAM bottlenecks throw scaning key space in real time and aggregate RAM usage statistic by patterns.
Stars: ✭ 591 (+823.44%)
Mutual labels:  memory-management
Sralloc
Memory allocators
Stars: ✭ 25 (-60.94%)
Mutual labels:  memory-management
Elm Syntax Highlight
Syntax highlighting in Elm
Stars: ✭ 61 (-4.69%)
Mutual labels:  syntax
Go Pmem
Native persistent memory support for Go
Stars: ✭ 57 (-10.94%)
Mutual labels:  memory-management
Explain Rs
A library which finds language features in rust code and provides resources on them.
Stars: ✭ 34 (-46.87%)
Mutual labels:  syntax

WeakableSelf

platforms pod Carthage compatible

Context

Closures are one of Swift must-have features, and Swift developers are aware of how tricky they can be when they capture the reference of an external object, especially when this object is self.

To deal with this issue, developers are required to write additional code, using constructs such as [weak self] and guard, and the result looks like the following:

service.call(completion: { [weak self] result in
    guard let self = self else { return }
    
    // use weak non-optional `self` to handle `result`
})

Purpose of WeakableSelf

The purpose of this micro-framework is to provide the developer with a helper function weakify that will allow him to declaratively indicate that he wishes to use a weak non-optional reference to self in closure, and not worry about how this reference is provided.

Usage

Using this weakify function, the code above will be transformed into the much more concise:

import WeakableSelf

service.call(completion: weakify { strongSelf, result in    
    // use weak non-optional `strongSelf` to handle `result`
})

weakify works with closures that take up to 7 arguments.

Installation

Requirements

  • Swift 4.2+
  • Xcode 10+

CocoaPods

Add the following to your Podfile:

pod "WeakableSelf"

Carthage

Add the following to your Cartfile:

github "vincent-pradeilles/weakable-self"

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].