shoes / shoes3

a tiny graphical app kit for ruby
http://walkabout.mvmanila.com
Other
181 stars 19 forks source link

sticky shoes urls #187

Closed ccoupe closed 8 years ago

ccoupe commented 8 years ago

If one uses the url/visit method of creating a shoes App, if you run then run a second one which also uses url/visit in the same Shoes process (like the manual will do) it always uses the first app for url '/' even if you closed it. Congratulations to @passenger94 for even noticing this very odd behaviour in #148 and even better for providing options to fix it.

regarding url, with this change in shoes.rb, it fixes the problem in manual

  def self.mount(path, meth, &blk)
    unless @mounts.empty?
      # checking if app changed
      @mounts.clear if meth[0] != @mounts[0][1][0]
    end
    @mounts << [path, meth || blk]
  end

meth is an array whose first member is the self of the Class who subclasses Shoes, so checking if it has changed should work ... Otherwise @mounts is appending paths, no matter what and Shoes take the first one it finds... Another approach could be to always take the last one (the more up to date)... or prepend to the array

def self.mount(path, meth, &blk)
  @mounts.unshift([path, meth || blk])
end
ccoupe commented 8 years ago

I have no strong opinion of what is the best solution. Maybe remove the @mount when the app was closed? What if someone really want two Apps on screen so there should be two "/" urls.. I do lean towards allowing that to happen so maybe visit needs some help?

This is also related to other complaints about APPS and app (see)[https://github.com/Shoes3/shoes3/wiki/Poking-in-Shoes.app] and Irb/byebug ability to get inside an App.

passenger94 commented 8 years ago

Hehe interesting !!! If we open several "Class" app at the same time, via a regular Shoes.app (Case of the Manual app) there is a clash with the '/' route (that route is the mandatory entry point for all app created via subclassing Shoes) so there can be only one '/' route per Shoes session. (of course you have to take care that other routes are specific to each app - not the same -) Obvious workaround is to open two shoes session (no simple communication though) ! Now this is a super edge case as except for Manual where we want to show demos of possible Shoes apps, one probably never want to do that. Manual showing one app after the other (ie once first is closed) is possible with the fix.

Also there is two visit methods one Ruby, one C :

So, unless you are Yma Sumac (please double check), messing in this amazing fancy dress is going to happen over my dead body :-D !

ccoupe commented 8 years ago

I am not Yma Sumac (R.I.P) and I don't want to mess with your your dress with a variable '/'