Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventLoop

type EventLoop struct {
	// contains filtered or unexported fields
}

func NewEventLoop

func NewEventLoop(opts ...Option) *EventLoop

func (*EventLoop) ClearInterval

func (loop *EventLoop) ClearInterval(i *Interval)

    ClearInterval cancels an Interval returned by SetInterval. ClearInterval is safe to call inside or outside of the loop.

    func (*EventLoop) ClearTimeout

    func (loop *EventLoop) ClearTimeout(t *Timer)

      ClearTimeout cancels a Timer returned by SetTimeout if it has not run yet. ClearTimeout is safe to call inside or outside of the loop.

      func (*EventLoop) Run

      func (loop *EventLoop) Run(fn func(*goja.Runtime))

        Run calls the specified function, starts the event loop and waits until there are no more delayed jobs to run after which it stops the loop and returns. The instance of goja.Runtime that is passed to the function and any Values derived from it must not be used outside of the function. Do NOT use this function while the loop is already running. Use RunOnLoop() instead. If the loop is already started it will panic.

        func (*EventLoop) RunOnLoop

        func (loop *EventLoop) RunOnLoop(fn func(*goja.Runtime))

          RunOnLoop schedules to run the specified function in the context of the loop as soon as possible. The order of the runs is preserved (i.e. the functions will be called in the same order as calls to RunOnLoop()) The instance of goja.Runtime that is passed to the function and any Values derived from it must not be used outside of the function. It is safe to call inside or outside of the loop.

          func (*EventLoop) SetInterval

          func (loop *EventLoop) SetInterval(fn func(*goja.Runtime), timeout time.Duration) *Interval

            SetInterval schedules to repeatedly run the specified function in the context of the loop as soon as possible after every specified timeout period. SetInterval returns an Interval which can be passed to ClearInterval. The instance of goja.Runtime that is passed to the function and any Values derived from it must not be used outside of the function. SetInterval is safe to call inside or outside of the loop.

            func (*EventLoop) SetTimeout

            func (loop *EventLoop) SetTimeout(fn func(*goja.Runtime), timeout time.Duration) *Timer

              SetTimeout schedules to run the specified function in the context of the loop as soon as possible after the specified timeout period. SetTimeout returns a Timer which can be passed to ClearTimeout. The instance of goja.Runtime that is passed to the function and any Values derived from it must not be used outside of the function. SetTimeout is safe to call inside or outside of the loop.

              func (*EventLoop) Start

              func (loop *EventLoop) Start()

                Start the event loop in the background. The loop continues to run until Stop() is called. If the loop is already started it will panic.

                func (*EventLoop) Stop

                func (loop *EventLoop) Stop()

                  Stop the loop that was started with Start(). After this function returns there will be no more jobs executed by the loop. It is possible to call Start() or Run() again after this to resume the execution. Note, it does not cancel active timeouts. It is not allowed to run Start() and Stop() concurrently. Calling Stop() on an already stopped loop or inside the loop will hang.

                  type Interval

                  type Interval struct {
                  	// contains filtered or unexported fields
                  }

                  type Option

                  type Option func(*EventLoop)

                  func EnableConsole

                  func EnableConsole(enableConsole bool) Option

                    EnableConsole controls whether the "console" module is loaded into the runtime used by the loop. By default, loops are created with the "console" module loaded, pass EnableConsole(false) to NewEventLoop to disable this behavior.

                    type Timer

                    type Timer struct {
                    	// contains filtered or unexported fields
                    }

                    Source Files