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

stop() method is never called in cached controllers #142

Closed
masterdany88 opened this issue Sep 11, 2020 · 3 comments
Closed

stop() method is never called in cached controllers #142

masterdany88 opened this issue Sep 11, 2020 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@masterdany88
Copy link
Contributor

Please add possibility to stop() cached controllers.
We have method:
router.clearCache();
Whenever We wanna clear caches it is a good place to call stop() method on each cached controllers- f.e.: when You logs out from app.

Second option would be add method f.e.:
<C extends AbstractComponentController<?, ?, ?>> void removeFromCacheAllControllers();
so when User logs out he can trigger cache clean up.

I think whenever cached controller is removed from cache it should execute its stop() method, cause start method (start caching controller) is executed, but stop method is never executed.

start()/stop() methods starts controllers and its tasks( timers/ handlers etc)
activate()/deactivate() methods are triggered when controller/view is routed to and out and some task may run in background.

We need to have stop() be triggered.

@FrankHossfeld FrankHossfeld self-assigned this Sep 11, 2020
@FrankHossfeld FrankHossfeld added the bug Something isn't working label Sep 11, 2020
@FrankHossfeld FrankHossfeld added this to the 2.1.0 milestone Sep 11, 2020
@FrankHossfeld
Copy link
Collaborator

Some assumptions:

ComponentController
storeInCache(this)
Adds the controller to the store of cached controllers. Call this method from inside the controller you like to cache.
This method will not call the start- and activate-method of the controller.

removeFromCache(this)
Removes the controller from the store of cached controllers. Call this method from inside the controller you like to remove from the cache. In case the controller is not cached, the method does nothing.
This method will not call the deactivate- and stop-method of the controller.

clearControllerCache()
Clears the cache! This method will remove all cached controllers from the store.
For every controller the method will iterate over

  • the composites and call deactivate- and stop-method
  • once done, it call the deactivate- and stop-method of the controller.

DO NOT CALL THIS METHOD INSIDE A CACHED CONTROLLER!
If you are inside a cached controller, call removeFromCache(this) first!

ComponentCompositeController
storeInCache(this)
Adds the controller to the store of cached controllers. Call this method from inside the controller you like to cache.
This method will not call the start- and activate-method of the controller.

removeFromCache(this)
Removes the controller from the store of cached controllers. Call this method from inside the controller you like to remove from the cache. In case the controller is not cached, the method does nothing.
This method will not call the deactivate- and stop-method of the controller.

clearControllerCache()
Clears the cache! This method will remove all cached controllers from the store.
For every controller the method will call the deactivate- and stop-method of the controller.
DO NOT CALL THIS METHOD INSIDE A CACHED CONTROLLER!
If you are inside a cached controller, call removeFromCache(this) first!

@FrankHossfeld
Copy link
Collaborator

Please, switch the Nalu version to HEAD-SNAPSHOT and try again. Just deployed a new SNAPSHOT version containing the fix. Keep in mind, that the Debug annotation is no longer supported. Just delete the code, if you have used it.
If you ran into problems reopen the issue

@FrankHossfeld
Copy link
Collaborator

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants