entity

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 2 Imported by: 0

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 Entity implementation. The zero value will generate a unique ObjectId the first time it is read.

Deprecated: This is no longer used and will be removed in a future version

func (*Entity) ObjectId deprecated

func (e *Entity) ObjectId() ObjectId

Deprecated: This is no longer used and will be removed in a future version

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 is no longer used and will be removed in a future version

func NewObjectId deprecated

func NewObjectId() ObjectId

NewObjectId returns a new guaranteed atomically unique ObjectId.

Deprecated: This is no longer used and will be removed in a future version

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 is no longer used and will be removed in a future version

Jump to

Keyboard shortcuts

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