-
Notifications
You must be signed in to change notification settings - Fork 50
JavaScript Decorator Functions
You can define your own custom decorator functions, and they work as they normally do in Python. New to decorators? See TheCodeShips post on it here.
The JavaScript backend also defines some special decorators you can use to trigger some options. The following special decorators are applied at transpile time, not runtime.
Marks a function as redefinable at runtime, even when the --release
options is used.
The special method redefine
can then be used to redefine the function at runtime.
@redef
def myfunc():
pass
def foo():
print 'foo'
myfunc.redefine(foo)
The example above changes myfunc
to use foo
You can also pass a string to the redefine
method, the string must be JavaScript, not Python (the transpiler is not available at runtime).
https://github.com/rusthon/Rusthon/blob/master/examples/javascript_redefine_function.md