JavaScriptKit Documentation

Protocol JSClosure​Protocol

public protocol JSClosureProtocol: JSValueCompatible  

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.

%135 JSClosureProtocol JSClosureProtocol JSValueCompatible JSValueCompatible JSClosureProtocol->JSValueCompatible JSOneshotClosure JSOneshotClosure JSOneshotClosure->JSClosureProtocol JSClosure JSClosure JSClosure->JSClosureProtocol

Conforms To


Types Conforming to JSClosure​Protocol


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.


JSClosure represents a JavaScript function the body of which is written in Swift. This type can be passed as a callback handler to JavaScript functions.



func release() 

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