Eel icon indicating copy to clipboard operation
Eel copied to clipboard

Why does Eel have the function _expose protected?

Open nricciardi opened this issue 2 years ago • 1 comments

Hi (I'm new), my question is why does Eel have the function _expose protected?

It is a very handy feature in case you want to expose methods instead of function in case there are multiple classes having the same methods (very likely in the case of inheritance)... now you have to do this:

import eel


class MyClass:
   def my_method(self):
      pass
      
my_class = MyClass()
eel._expose("other_name", my_class.my_method)

Couldn't you add an alias parameter to .expose(...)?

nricciardi avatar Mar 31 '23 16:03 nricciardi

I don't think this was a deliberate design decision, I just initially only thought of using it as a decorator. _expose() is just an implementation detail that I didn't realise you could use like this.

I don't think there's anything wrong with it, and it could be made part of the public API but I would personally wrap my_class.my_method in a function.

ChrisKnott avatar Mar 31 '23 17:03 ChrisKnott