Skip to content

Add unbind and clearAllLifecycleObservers methods to View class #23

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shalaga44
Copy link
Member

Summary

This pull request adds two new methods to the View class to improve lifecycle observer management:

  1. unbind(lifecycleObserver: LifecycleObserver)

    • Allows removing a specific LifecycleObserver from a View.
  2. clearAllLifecycleObservers()

    • Provides a way to remove all bound LifecycleObservers from a View.

Changes

  • View Class Updates:

    • Added the unbind method to remove a single observer.
    • Added the clearAllLifecycleObservers method to remove all observers at once.
  • Testing:

    • Created tests in the LifecycleObserverTest class.
    • Tests cover both new methods to ensure they work as expected.

Benefits

  • Enhanced Control:

    • Developers can now unbind observers when they are no longer needed.
    • Simplifies the process of cleaning up observers.
  • Resource Management:

    • Helps prevent potential memory leaks by ensuring observers do not remain bound unnecessarily.
    • Improves the efficiency of the application by managing observers effectively.

Testing Details

  • testUnbindLifecycleObserver:

    • Verifies that after unbinding, the observer no longer receives lifecycle events.
  • testClearAllLifecycleObservers:

    • Ensures that all observers are removed and none receive events after clearing.

Conclusion

These additions enhance the View class by providing better lifecycle observer management, making it easier to maintain and improve application performance.

@shalaga44 shalaga44 requested a review from Kabbura October 28, 2024 08:44
@shalaga44 shalaga44 assigned Kabbura and unassigned Kabbura Nov 9, 2024
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.

2 participants