Skip to content

Instantly share code, notes, and snippets.

@sisoje
Last active August 18, 2020 15:01

Revisions

  1. sisoje revised this gist Feb 1, 2019. No changes.
  2. sisoje revised this gist Feb 1, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions DeinitBlock.swift
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    public class DeinitBlock {
    class DeinitBlock {
    let onDeinit: () -> Void
    public init(_ block: @escaping () -> Void) {
    init(_ block: @escaping () -> Void) {
    onDeinit = block
    }
    deinit {
  3. sisoje revised this gist Feb 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion DeinitBlock.swift
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    public class DeinitBlock {
    let onDeinit: () -> Void
    public init(_ block: @escaping () -> Void) {
    self.onDeinit = block
    onDeinit = block
    }
    deinit {
    onDeinit()
  4. sisoje revised this gist Jan 31, 2019. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion DeinitBlock.swift
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@
    //
    public class DeinitBlock {
    let onDeinit: () -> Void
    public init(_ block: @escaping () -> Void) {
  5. sisoje renamed this gist Jan 31, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. sisoje revised this gist Jan 31, 2019. 2 changed files with 1 addition and 8 deletions.
    1 change: 1 addition & 0 deletions DeinitBlock
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    //
    public class DeinitBlock {
    let onDeinit: () -> Void
    public init(_ block: @escaping () -> Void) {
    8 changes: 0 additions & 8 deletions URLSessionDataTask
    Original file line number Diff line number Diff line change
    @@ -1,8 +0,0 @@
    extension URLSessionDataTask {
    func taskRunner() -> DeinitBlock {
    resume()
    return DeinitBlock {
    self.cancel()
    }
    }
    }
  7. sisoje renamed this gist Jan 31, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. sisoje revised this gist Jan 31, 2019. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions URLSessionDataTask
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    extension URLSessionDataTask {
    func taskRunner() -> DeinitBlock {
    resume()
    return DeinitBlock {
    self.cancel()
    }
    }
    }
  9. sisoje created this gist Jan 31, 2019.
    9 changes: 9 additions & 0 deletions DeinitBlock.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    public class DeinitBlock {
    let onDeinit: () -> Void
    public init(_ block: @escaping () -> Void) {
    self.onDeinit = block
    }
    deinit {
    onDeinit()
    }
    }