-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Miscellaneous improvements/changes (#138)
* Add the ability to get all component types registered * Tags: changed to a single string: can name them as you create them * Update tag.go * Fix test
- Loading branch information
Showing
5 changed files
with
52 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
package donburi | ||
|
||
type Tag string | ||
|
||
// NewTag is an utility to create a tag component. | ||
// Which is just an component that contains no data. | ||
func NewTag() *ComponentType[struct{}] { | ||
return NewComponentType[struct{}]() | ||
// Specify a string as the first and only parameter if you wish to name the component. | ||
func NewTag(opts ...any) *ComponentType[Tag] { | ||
if len(opts) == 0 { | ||
return NewComponentType[Tag]() | ||
} | ||
first, ok := opts[0].(string) | ||
if !ok { | ||
return NewComponentType[Tag]() | ||
} | ||
c := NewComponentType[Tag](Tag(first)) | ||
c.SetName(first) | ||
return c | ||
} |