{"id":14961780,"url":"https://github.com/quasilyte/gsignal","last_synced_at":"2025-10-24T22:30:48.218Z","repository":{"id":65695860,"uuid":"595073205","full_name":"quasilyte/gsignal","owner":"quasilyte","description":"A lightweight Godot/Qt inspired signals and slots for Go","archived":false,"fork":false,"pushed_at":"2024-08-02T12:06:07.000Z","size":16,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-31T04:26:03.505Z","etag":null,"topics":["ebiten","ebitengine","event","event-listener","gamedev","ge","go","godot","golang","qt","signal-slot","signals"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quasilyte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-30T10:39:07.000Z","updated_at":"2024-09-15T13:51:32.000Z","dependencies_parsed_at":"2024-09-02T17:03:09.867Z","dependency_job_id":"18cb99e2-d5dd-4545-9754-f387ef7a9ede","html_url":"https://github.com/quasilyte/gsignal","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Fgsignal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Fgsignal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Fgsignal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Fgsignal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quasilyte","download_url":"https://codeload.github.com/quasilyte/gsignal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238039755,"owners_count":19406395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ebiten","ebitengine","event","event-listener","gamedev","ge","go","godot","golang","qt","signal-slot","signals"],"created_at":"2024-09-24T13:27:33.281Z","updated_at":"2025-10-24T22:30:42.921Z","avatar_url":"https://github.com/quasilyte.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Godot-like signals library\n\n![Build Status](https://github.com/quasilyte/gsignal/workflows/Go/badge.svg)\n[![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/quasilyte/gsignal)](https://pkg.go.dev/mod/github.com/quasilyte/gsignal)\n\n### Overview\n\nA [Godot](https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html)-inspired signals library for Go.\n\n**Key features:**\n\n* Amortized zero allocations in most use cases\n* Efficient `Connect`, `Emit`, `Disconnect`\n* Generic-based API gives us type safety and convenience\n\nSome games that were built with this library (this list is incomplete):\n\n* [Roboden](https://quasilyte.itch.io/roboden)\n* [Cavebots](https://quasilyte.itch.io/cavebots)\n* [Assemblox](https://quasilyte.itch.io/assemblox)\n* [Decipherism](https://quasilyte.itch.io/decipherism)\n* [Retrowave City](https://quasilyte.itch.io/retrowave-city)\n* [Autotanks](https://quasilyte.itch.io/autotanks)\n* [Sinecord](https://quasilyte.itch.io/sinecord)\n* [Learn Georgian](https://quasilyte.itch.io/georgian-trainer)\n\nWhy bother and use something like this?\n\n* It reduces the objects coupling\n* It's an elegant event listener solution for Go\n* Signals are a familiar concept (Godot, Phaser, Qt, ...)\n\n### Installation\n\n```bash\ngo get github.com/quasilyte/gsignal\n```\n\n### Quick Start\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/quasilyte/gsignal\"\n)\n\ntype button struct {\n\tName         string\n\tEventClicked gsignal.Event[*button]\n}\n\nfunc (b *button) Click() { b.EventClicked.Emit(b) }\n\ntype listener struct {\n\tdisposed bool\n}\n\nfunc (l *listener) IsDisposed() bool { return l.disposed }\n\nfunc (l *listener) onClick(b *button) {\n\tfmt.Println(\"listener on click\")\n}\n\nfunc main() {\n\tb := \u0026button{Name: \"example\"}\n\tb.Click() // nothing happens, 0 connections\n\n\ti := 1\n\tb.EventClicked.Connect(nil, func(b *button) {\n\t\tfmt.Printf(\"%s clicked (%d)\\n\", b.Name, i)\n\t\ti++\n\t})\n\tb.Click() // prints \"example clicked (1)\" once\n\tb.Click() // prints \"example clicked (2)\" once; again\n\n\tl := \u0026listener{}\n\tb.EventClicked.Connect(l, l.onClick)\n\tb.Click() // prints \"example clicked (3)\", then \"listener on click\"\n\n\tl.disposed = true // this will cause a disconnect\n\tb.Click()         // prints \"example clicked (4)\" once\n}\n```\n\n### Introduction\n\nThis concept is borrowed from [Godot signals](https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html), but it also resembles [Signals and Slots from Qt](https://doc.qt.io/qt-6/signalsandslots.html).\n\nIn `gsignal` terms:\n\n* `Signal` = a field inside a struct\n* `Slot` = a function (or method value) bound to a signal\n* `Disconnect` = remove bound function\n* `Emit` = call all bound functions\n\nThis library disconnects **disposed** objects automatically. This is convenient when you connect a scene object to some `Event`. When object goes away from a scene (becomes disposed), there is no need to call its event handler anymore.\n\n### Thread Safety Notice\n\nThis library never does any synchronization on its own. It's implied that event emitters and their subscribers are executed inside the same goroutine.\n\nThis is possible in the game context, but it may not be as easy to enforce in some other applications.\n\nLet's imagine that you want to do a background task in a game and provide a signal-style event for its completion. You spawn a goroutine for the task, but you keep the code outside look like it's still single-threaded. All concurrent communication should be incapsulated in the object owning the `Event` object. When this object knows that this concurrent job is completed, it should emit the event and notify all the subscribers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquasilyte%2Fgsignal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquasilyte%2Fgsignal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquasilyte%2Fgsignal/lists"}