JavaScriptKit Documentation

Class JSOneshot​Closure

public class JSOneshotClosure: JSObject, JSClosureProtocol  

JSOneshotClosure is a JavaScript function that can be called only once. This class can be used for optimized memory management when compared to the common JSClosure.

%163 JSOneshotClosure JSOneshotClosure JSClosureProtocol JSClosureProtocol JSOneshotClosure->JSClosureProtocol JSObject JSObject JSOneshotClosure->JSObject



JSObject represents an object in JavaScript and supports dynamic member lookup. Any member access like will dynamically request the JavaScript and Swift runtime bridge library for a member with the specified name in this object.

Conforms To


JSClosureProtocol wraps Swift closure objects for use in JavaScript. Conforming types are responsible for managing the lifetime of the closure they wrap, but can delegate that task to the user by requiring an explicit release() call.



public init(_ body: @escaping ([JSValue]) -> JSValue, file: String = #fileID, line: UInt32 = #line)  



public func release()  

Release this function resource. After calling release, calling this function from JavaScript will fail.