PythonMonkey   v0.8.2 (dev)
Loading...
Searching...
No Matches
pythonmonkey.pythonmonkey.JSMethodProxy Class Reference
Inheritance diagram for pythonmonkey.pythonmonkey.JSMethodProxy:
[legend]
Collaboration diagram for pythonmonkey.pythonmonkey.JSMethodProxy:
[legend]

Public Member Functions

None __init__ (self)
 

Detailed Description

JavaScript Method proxy
This constructs a callable object based on the first argument, bound to the second argument
Useful when you wish to implement a method on a class object with JavaScript
Example:
import pythonmonkey as pm

jsFunc = pm.eval("(function(value) { this.value = value})")
class Class:
  def __init__(self):
    self.value = 0
    self.setValue = pm.JSMethodProxy(jsFunc, self) #setValue will be bound to self, so `this` will always be `self`

myObject = Class()
print(myObject.value) # 0
myObject.setValue(42)
print(myObject.value) # 42.0

Constructor & Destructor Documentation

◆ __init__()

None pythonmonkey.pythonmonkey.JSMethodProxy.__init__ (   self)

The documentation for this class was generated from the following file: