It is exposed through the global variable std and has everything needed to interact with the runtime and other helpers.

resolve

Takes a class reference and gets its instance from the DI container.

classReference
Class
required

A reference to a class participating in Dependency Injection

Example

To retreive an instance of a class called LoadBalancer, you’d write:

  const loadBalancer = std.resolve(LoadBalancer);
If the param is a class that is not decorated with @Injectable then this will throw an error!

flow

Helper to create flows.

name
string
required

Name of the flow

classInstance
Object
required

An instance of a class

schedule
Object
{ after: number } | { every: number }

This param enables you to create Scheduled Flows


log

Equivalent of console.log. Halts the execution.

messages
...any[]

You can pass any number of messages of any type.

Example

  std.log("This is pretty", 1337);

lambda

This is experimental
Wrapper to skip higher order functions getting transformed by compiler. See this.

fn
Function
required

The function you want to pass around.


currentTick

Equivalent to System.currentTimeMillis() or Date.now() but follows temporal rules of runtime.

tick
number

Returns the current tick/time.


sleep

Halts the flow for given number of ticks.

ticks
number
required

Number of ticks the flow should halt for.


awaitAll

Suspends the current flow till all the given flows complete. See here.

flowExecutors
FlowExecutor[]
required

The flows you want to await on.


awaitRace

Suspends the current flow till one of the given flows complete. See here.

flowExecutors
FlowExecutor[]
required

The flows you want to race.


createChannelEmitter

Creates a channel emitter which lets you push events for given topic. See this.

topic
string
required

A dedicated channel will be created for the topic.


registerChannelListener

Lets you susbscribe to topics. See this.

topic
string
required

The topic to listen.

listener
(data: T) => FlowExecutor
required

The function to invoke whenever there’s an event pushed for given topic.