Documentation
¶
Index ¶
- func Component[T any](e Components, key any) (res T, ok bool)
- func ComponentType[T any](e Components) (T, bool)
- func Nil(e Components) bool
- func SetComponent(e Components, key any, val any)
- func SetComponentType[T any](e Components, val T)
- type Components
- type Entitydeprecated
- func (e *Entity) ObjectId() ObjectIddeprecated
- type ObjectIddeprecated
- func NewObjectId() ObjectIddeprecated
- type ObjectIderdeprecated
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 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