modelid

package
v0.0.0-...-9947234 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package modelid provides a way to identify a specific model instance by providing a global counter that is incremented each time a new model is created.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID uint

ID is a unique identifier for a model

It can be used to identify a specific instance of a model within a collection of models, which is useful when you need to update a specific model using a message

Create a new ID using Next

func Next

func Next() ID

Next returns the next available ID

The ID generated is unique within the process, but is not guaranteed to be unique across restarts

func (ID) Matches

func (id ID) Matches(msg MsgForModelID) bool

Matches returns true if the given message is for the model with the given ID

type MsgForModelID

type MsgForModelID interface {
	tea.Msg
	ForModelID() ID
}

MsgForModelID is a message that is associated with a [ModelID]

Implement this interface on your tea.Msg to allow it to work with [ModelID.Matches] method.

Jump to

Keyboard shortcuts

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