entity

package
v0.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Component added in v0.11.0

func Component[T any](e Components, key any) (res T, ok bool)

func ComponentType added in v0.11.0

func ComponentType[T any](e Components) (T, bool)

func Nil added in v0.11.0

func Nil(e Components) bool

func SetComponent added in v0.11.0

func SetComponent(e Components, key any, val any)

func SetComponentType added in v0.11.0

func SetComponentType[T any](e Components, val T)

Types

type Components added in v0.11.0

type Components interface {
	// contains filtered or unexported methods
}

Components allow storing and retrieving components associated with an entity. This is very inspired by the idea of an Entity Component System.

Keys must be non-nil and comparable. Methods will panic if the key is nil or not comparable. When using string values as keys, it's advisable to create a new type for the keys to avoid name collision with keys from other parts of the code.

Example usages:

  • The JavaScript wrapper for a component is stored in the component.
  • Test code stores a *testing.T in the window object, allowing assertions in JavaScript to integrate with Go tests.

See also: https://en.wikipedia.org/wiki/Entity_component_system

type Entity deprecated

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

Entity is the default Components implementation.

Deprecated: This will likely be renamed or moved to an internal package

type ObjectId deprecated

type ObjectId = int32

An ObjectId uniquely identifies an element in the DOM. It is meant for internal use only, and shouldn't be used by users of the library.

The value is a 32bit integer so it can accurately be represented by a JavaScript number.

Deprecated: This will likely be moved to an internal package

func NewObjectId deprecated

func NewObjectId() ObjectId

NewObjectId returns a new guaranteed atomically unique ObjectId.

Deprecated: This will likely be moved to an internal package

type ObjectIder deprecated added in v0.5.0

type ObjectIder interface {
	ObjectId() ObjectId
}

An ObjectIder provides a unique identifier of an object that may be retrieved from the DOM. It is part of a solution to ensure the same JS object is returned for the same DOM element.

Deprecated: This will likely be moved to an internal package

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL