Skip to content

[Plugs] Expose a syscall to register a new function #1004

Open
@zefhemel

Description

@zefhemel

You can currently only define custom functions (https://silverbullet.md/Functions) in space script, not through plugs. This is a bit silly and should be made possible.

Likely design:

system.registerFunction({name: "myFunction"}, `() => 10`);

The second argument will need to be a string with JavaScript code (to be eval'ed) because custom functions must (for performance reasons) run in the main browser thread. So we need to ship the code from a plug over to the main thread in JavaScript text form, unfortunately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreRequires extension of SB’s coreenhancementNew feature or requestplugCan be implemented as a plug

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions