LogoAntiRaid

@antiraid-ext/once

API reference for @antiraid-ext/once

@antiraid-ext/once

Functions

once

Stores local `once` calls to avoid re-execution

Runs a function only once, when the template is first ever

executed

``@antiraid/kv`` is used for persistence here to avoid rerunning

the function on worker restart

Function Signature
-- Stores local \`once\` calls to avoid re-execution
--- Runs a function only once, when the template is first ever 
--- executed
---
--- \`\`@antiraid/kv\`\` is used for persistence here to avoid rerunning
--- the function on worker restart
function once<T>(ctx: Primitives.TemplateContext, globalid: string, fn: () -> T) -> T? end

Generics

T

This generic is unconstrained and can be any type

Arguments

ctx

Primitives.TemplateContext

globalid

string

fn

Function Signature
fn: () -> T

Returns

ret1

T

Returns

ret1

T?

onceLocal

Runs a function only once, when the template is first ever

executed. If the function errors, it will be re-executed on future runs

Unlike ``once``, this function is not persistent across worker restarts

Function Signature
--- Runs a function only once, when the template is first ever 
--- executed. If the function errors, it will be re-executed on future runs
---
--- Unlike \`\`once\`\`, this function is not persistent across worker restarts
function onceLocal<T>(localid: string, fn: () -> T) -> T? end

Generics

T

This generic is unconstrained and can be any type

Arguments

localid

string

fn

Function Signature
fn: () -> T

Returns

ret1

T

Returns

ret1

T?

Last updated on