Closed aaronpearce closed 4 years ago
Hey, thanks for the PR. Is there any particular reason for the design choice that the completion block is a property on the HUD? This seems unconventional and will easily lead to retain cycles if people are not careful. I'd opt for a design where the completion block is passed as a parameter to a dismiss function, i.e. -[JGProgressHUD dismiss:withCompletion:]
.
I believe I implemented it this way to minimise changes within all the dismiss methods. Its also done the same as the other blocks such as tapOutsideBlock
and tapOnHUDViewBlock
True about the other blocks, although they are somewhat different in the sense that they do not trigger upon some method call (unlike the dismiss completion block) but happen asynchronously when the user performs some action.
The other reason I did it this was so I did not need to create delegate methods scattered throughout my code unnecessarily. I only needed the one dismissal callback. This way makes my code tidier overall.
Personally, I'm for passing the closure into the dismiss(), not as a property. The code may look cleaner but the chance of a retain cycle if someone isn't careful is too high in my opinion.
@aaronpearce I will close it now as I implemented this feature in 8ffc8faba6d31bfd457e1582d24bba5853caa09d where I made the changes that I wanted (i.e. adding a block to the dismiss method directly). But thanks anyway, this was still some good input.
Fixes #127.
This adds a basic completion block to be called when dismissal is completed alongside the existing delegates.
Could possibly also add a handler for willDismiss if wanted.