Interface
JavaScript interface
These functions can be called in the browser and are written in JavaScript.
PlutoBoard.callJuliaFunction
— Methodasync callJuliaFunction(
func_name,
{ args = [], kwargs = {}, response_callback = () => { }, internal = false } = {}
) -> Promise
Calls specified Julia function with args and callback within browser context from JavaScript.
Args:
func_name: String
: Function name of the called Julia function
Kwargs:
args: Array
: Args for the Julia functionkwargs: Dict
: Kwargs for the Julia functionresponse_callback: Function
: Function that gets called when a new message is being sent from the Julia functioninternal: Boolean = false
: Whether the targeted function is in PlutoBoard package. Only used for internal calls, defaults to false
Example usage:
callJuliaFunction("get_cube", {
args: [number],
response_callback: (
r => {
const outP = document.getElementById("buttonOutput");
outP.innerHTML = `Cube of ${number}... ${Math.round(r * 100)}%`;
}
)
}).then(
r => {
const outP = document.getElementById("buttonOutput");
outP.innerHTML = `The cube of ${number} is ${r}`;
}
)
Julia interface
PlutoBoard.initialize
— Methodinitiliaize(
html_path::String,
;
hide_notebook::Bool = true,
scripts::Array{String} = [],
links::Array{String} = [],
) -> nothing
Initializes the PlutoBoard module with parameters. scripts
and links
are urls to scripts and stylesheets.
PlutoBoard.send_to_ws
— Methodsend_to_ws(
ws::WebSocket,
message::String
)
Send a message to a WebSocket as response. This triggers callback
in callJuliaFunction
.
PlutoBoard.run
— Functionrun(debug::Bool=false)
Runs the Pluto notebook with the PlutoBoard notebook. If debug
is true, the notebook will reload when the file changes. Additionally copies the interface.js file to the lib directory of the current directory.