Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CIS-1238] Remove AnyXXXXControllerDelegate Boilerplate Code #1564

Merged
merged 19 commits into from Oct 21, 2021

Conversation

nuno-vieira
Copy link
Member

@nuno-vieira nuno-vieira commented Oct 19, 2021

🔗 Issue Link

CIS-1238

🎯 Goal

Remove the AnyXXXXControllerDelegate boilerplate code, which complicates a lot when adding or creating delegates for our controllers in the Low-Level SDK. Since we don't have the generic ExtraData anymore, this boilerplate code is not needed.

🛠 Implementation

By refactoring the MulticastDelegate and making sure the delegates are weakly referenced, we can totally discard the AnyXXXXControllerDelegate implementations.

🧪 Testing

A QA Run should be made to make sure nothing was broken.

@b-onc should also make sure the current implementation is correct, and it is compared with the old one. (I'm still not sure why we needed a "main" delegate before, but if this is necessary, we can put this back with the current implementation) Update: After discussing with Bahadir, I added back the mainDelegate to MulticastDelegate.

🎨 Changes

N/A

☑️ Checklist

  • I have signed the Stream CLA (required)
  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Affected documentation updated (docusaurus, tutorial, CMS (task created))

@Stream-iOS-Bot
Copy link
Collaborator

Stream-iOS-Bot commented Oct 19, 2021

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

@nuno-vieira nuno-vieira changed the title [CIS-1238] Remove AnyXXXXControllerDelegate boilerplate code [CIS-1238] Remove AnyXXXXControllerDelegate Boilerplate Code Oct 19, 2021
@codecov
Copy link

codecov bot commented Oct 20, 2021

Codecov Report

Merging #1564 (e715403) into main (8fda2d0) will decrease coverage by 0.04%.
The diff coverage is 92.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1564      +/-   ##
==========================================
- Coverage   87.87%   87.82%   -0.05%     
==========================================
  Files         232      232              
  Lines       11029    10731     -298     
==========================================
- Hits         9692     9425     -267     
+ Misses       1337     1306      -31     
Flag Coverage Δ
llc-tests 87.82% <92.07%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...chController/MessageSearchController+Combine.swift 0.00% <0.00%> (ø)
...chController/MessageSearchController+SwiftUI.swift 0.00% <0.00%> (ø)
...sageSearchController/MessageSearchController.swift 0.00% <0.00%> (ø)
...ontrollers/EventsController/EventsController.swift 69.56% <50.00%> (-4.51%) ⬇️
.../ChannelController/ChannelController+Combine.swift 100.00% <100.00%> (ø)
.../ChannelController/ChannelController+SwiftUI.swift 100.00% <100.00%> (ø)
...trollers/ChannelController/ChannelController.swift 92.02% <100.00%> (-0.58%) ⬇️
...ListController/ChannelListController+Combine.swift 68.42% <100.00%> (ø)
...ListController/ChannelListController+SwiftUI.swift 68.42% <100.00%> (ø)
.../ChannelListController/ChannelListController.swift 84.66% <100.00%> (+1.15%) ⬆️
... and 28 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8fda2d0...e715403. Read the comment docs.

Copy link
Contributor

@b-onc b-onc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of open stuff, but looks solid!

Copy link
Contributor

@b-onc b-onc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple more points from me

Copy link
Contributor

@evsaev evsaev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@nuno-vieira nuno-vieira merged commit 033faae into main Oct 21, 2021
@nuno-vieira nuno-vieira deleted the tech/remove-any-delegates-boilerplate-code branch October 21, 2021 12:40
nuno-vieira added a commit that referenced this pull request Oct 21, 2021
* Refactor `MulticastDelegate`

* Change all controllers to the new `MulticastDelegate`

* Remove All `AnyXXXControllerDelegate` boilerplate code

* New `MulticastDelegate` Tests

* Remove unnecessary `mutating` keyword from `MulticastDelegate`

* Add back support for the main Delegate in `MulticastDelegate`

* Set all functions to mutating on `MulticastDelegate`

For some reason, without this the controller tests are not passing.
Switching to `class` also make all tests failing still.

* Fix MessageDTO_Tests

* Add tests to verify there are no retain cycles

* Add replace API to `MulticastDelegate` to replace the additional delegates

* Deprecate `setDelegate()`

* Update CHANGELOG.md

* Improve deprecated `setDelegate` implementation

* Remove `removeAll()` API from `MulticastDelegate`

* Change the `replace` API with `set(additionalDelegates:)` for consistency

* Move all deprecations to Deprecations.swift file

* Remove TestGenericDelegate leftover from ExtraData
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants