Skip to content

Instantly share code, notes, and snippets.

@Otbivnoe
Created September 12, 2017 07:23
Show Gist options
  • Select an option

  • Save Otbivnoe/a8fe8aacab888719028e00facd57cff6 to your computer and use it in GitHub Desktop.

Select an option

Save Otbivnoe/a8fe8aacab888719028e00facd57cff6 to your computer and use it in GitHub Desktop.
let disposable1 = Disposables.create { print("disposed-1 ☠️") }
let disposable2 = Disposables.create { print("disposed-2 ☠️") }
let singleAssignmentDisposable = SingleAssignmentDisposable()
print("set disposable1")
singleAssignmentDisposable.setDisposable(disposable1)
print("set disposable2")
singleAssignmentDisposable.setDisposable(disposable2) // ⚠️⚠️⚠️ fatal error
print("dispose")
singleAssignmentDisposable.dispose()
// log:
// set disposable1
// set disposable2
// ⚠️⚠️⚠️ fatal error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment