import { Callback } from "https://deno.land/x/python@0.3.1/src/python.ts";
Wraps a JS function into Python callback which can be passed to Python land. It must be destroyed explicitly to free up resources on Rust-side.
Example:
// Creating
const add = new Callback((_, a: number, b: number) => {
return a + b;
});
// or
const add = new Callback((kw: { a: number, b: number }) => {
return kw.a + kw.b;
});
// Usage
some_python_func(add);
// Destroy
add.destroy();