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