-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Suppose I want to implement a function on the client side, which is not specifically triggered by an event. Something like this:
class HellowWorldApp:
def initialize(self, **kwargs):
self.rdoc = kwargs['remote_document']
self.rdoc.body.element(h1='Hello World!!!').events.add(click=self.clicked, translate=True)
def clicked(self):
self.heavy_clientside_computation()
def heavy_clientside_computation(self):
# Do something heavy on the client's browserSo, by clicking on "Hello World" the "clicked" event is fired, but then the browser throws a JS Error because "heavy_clientside_computation(self)" was not compiled to Javascript and sent to the client..
Is there a solution for this now as the framework is?
If not, may I suggest something like a decorator so the framework knows which functions are to be sent to the client? It could be something like the following, and it could be applied to all "remote" methods, including those triggered by events (as python zen's explicit is better than implicit):
class HellowWorldApp:
def initialize(self, **kwargs):
self.rdoc = kwargs['remote_document']
self.rdoc.body.element(h1='Hello World!!!').events.add(click=self.clicked, translate=True)
@remotemethod
def clicked(self):
self.heavy_clientside_computation()
@remotemethod
def heavy_clientside_computation(self):
# Do something heavy on the client's browserIn this case, all function calls inside @remotemethod's would be local browser calls, unless there was the rpc() call, which would be targeting the server.