Skip to content

Add unbind and clearAllLifecycleObservers methods to View class#23

Open
shalaga44 wants to merge 1 commit intoNarbase:masterfrom
shalaga44:add-unbind-to-lifecycle-owner
Open

Add unbind and clearAllLifecycleObservers methods to View class#23
shalaga44 wants to merge 1 commit intoNarbase:masterfrom
shalaga44:add-unbind-to-lifecycle-owner

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