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

every and each unmounting... #395

Open
catmando opened this issue Mar 31, 2021 · 0 comments
Open

every and each unmounting... #395

catmando opened this issue Mar 31, 2021 · 0 comments
Labels
discussion needs on going discussion before resolving what kind of problem it is, and what to do with it. enhancement New feature or request

Comments

@catmando
Copy link
Contributor

every makes sense, as the timer will keep running for ever. But should any each timer that is still running when things unmount also be unmounted? Note that Observable includes AutoUnmount, so any store will get this behavior as well!

Then, on the other hand, there is an each! and every! method (they don't auto start, so you have to say each!(x).start. Neither of these timers IS auto-unmounted.

Couple of options:

  1. just take after out of unmount, and forgettabout it.
  2. 1 + provide a remove_after_timers method callable in Observable
  3. leave it, and if you want a timer that isn't unmounted use the bang variation.
  4. provide auto_unmount(x) attached to the timers so you say: after(12).auto_unmount(true) or every(12).auto_unmount(false) to override the defaults.

Currently I think its best to make both every and every! behave the same, and make each and each! not autounmount, and then add the auto_unmount method to the Browser::Interval and Browser::Delay classes.

  attr_accessor :mount_point

  def auto_unmount(yes)
     # warning message  and return if mount_point is nil
     if yes 
      AutoUnmount.objects_to_unmount[mount_point] << self 
     else
      AutoUnmount.objects_to_unmount[mount_point].delete(self)
    end
  end

  alias unmount abort

now all the automounter does is set mount_point

     def every!(*args, &block)
        super.tap do |id| 
           next id if unmounted?
           id.mount_point = self
           id.auto_unmount(true)
         end
      end
      def after!(*args, &block)
        super.tap { |id| id.mount_point = self unless unmounted? }
      end
@catmando catmando added enhancement New feature or request discussion needs on going discussion before resolving what kind of problem it is, and what to do with it. labels Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion needs on going discussion before resolving what kind of problem it is, and what to do with it. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant