[breaking] Remove automatic unsubscription from the Subscription object.
ClosedPublic

Authored by featherless on Apr 26 2017, 4:38 PM.

Details

Summary

This means that the disconnect method of observables will no longer be automatically invoked when the Subscription object is released.

This has several advantages:

  • Subscriptions no longer need to be explicitly maintained if unsubscription is unimportant to the subscriber.
  • The subscribe method's return value can now be marked ignorable, simplifying any call sites that don't care about unsubscribing.

The documentation for IndefiniteObservable has been updated to reflect the new behavior. Notably, we'd previously written that Subscriptions maintained a reference to the IndefiniteObservable chain; this isn't/wasn't technically true. Subscriptions only hold references to the chain of disconnect methods.

It is now possible to write expressions like so:

observable.subscribe { value in
  print(value)
}

With no explicit subscription storage required.

Diff Detail

Repository
R42 indefinite-observable-swift
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
featherless created this revision.Apr 26 2017, 4:38 PM
Restricted Application added a reviewer: O2: Material Motion. · View Herald TranscriptApr 26 2017, 4:38 PM
Restricted Application added a project: Material Motion. · View Herald Transcript
Restricted Application added a reviewer: O4: Material Apple platform reviewers. · View Herald Transcript
Restricted Application added a reviewer: Material Motion. · View Herald Transcript
markwei accepted this revision.Apr 26 2017, 4:41 PM
This revision is now accepted and ready to land.Apr 26 2017, 4:41 PM
  • Fix test.
This revision was automatically updated to reflect the committed changes.
randcode-generator added inline comments.
Podfile.lock
22

Is this file really needed?

featherless added inline comments.Apr 26 2017, 5:57 PM
Podfile.lock
22

May not be - I believe the material components for iOS team is considering removing it.