{"id":16464489,"url":"https://github.com/deatil/go-event","last_synced_at":"2025-03-21T06:31:57.000Z","repository":{"id":63549596,"uuid":"568626016","full_name":"deatil/go-event","owner":"deatil","description":"go-event 是一个 go 实现的事件及事件订阅库 / go-event is a go event pkg","archived":false,"fork":false,"pushed_at":"2024-08-28T15:35:12.000Z","size":81,"stargazers_count":13,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-17T22:08:23.906Z","etag":null,"topics":["event","events","go","go-event","listener"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/deatil/go-event","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deatil.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":"2022-11-21T03:50:37.000Z","updated_at":"2024-09-24T15:58:47.000Z","dependencies_parsed_at":"2024-02-21T17:26:59.015Z","dependency_job_id":"3c48c5df-4b19-46b5-bab1-b1adfaeabe6d","html_url":"https://github.com/deatil/go-event","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"c38c31c855968d03dd974cd2516fa779679c9b9b"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fgo-event","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fgo-event/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fgo-event/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fgo-event/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deatil","download_url":"https://codeload.github.com/deatil/go-event/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244751259,"owners_count":20504238,"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":["event","events","go","go-event","listener"],"created_at":"2024-10-11T11:28:03.517Z","updated_at":"2025-03-21T06:31:56.665Z","avatar_url":"https://github.com/deatil.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## go-event\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://pkg.go.dev/github.com/deatil/go-event\" target=\"_blank\"\u003e\u003cimg src=\"https://pkg.go.dev/badge/deatil/go-event.svg\" alt=\"Go Reference\"\u003e\u003c/a\u003e\n\u003ca href=\"https://app.codecov.io/gh/deatil/go-event\" target=\"_blank\"\u003e\u003cimg src=\"https://codecov.io/gh/deatil/go-event/graph/badge.svg?token=SS2Z1IY0XL\"/\u003e\u003c/a\u003e\n\u003cimg src=\"https://goreportcard.com/badge/github.com/deatil/go-event\" /\u003e\n\u003c/p\u003e\n\n\n### Desc\n\n*  go-event is a go event or event'subscribe pkg\n\n[中文](README_CN.md) | English\n\n\n### Download\n\n~~~go\ngo get -u github.com/deatil/go-event\n~~~\n\n\n### Get Starting\n\n~~~go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/deatil/go-event/event\"\n)\n\ntype TestEvent struct {}\n\nfunc (this *TestEvent) OnTestEvent(data any) {\n    fmt.Println(\"TestEvent: \")\n    fmt.Println(data)\n}\n\nfunc (this *TestEvent) OnTestEventName(data any, name string) {\n    fmt.Println(\"TestEventName: \")\n    fmt.Println(data)\n    fmt.Println(name)\n}\n\ntype TestEventPrefix struct {}\n\nfunc (this TestEventPrefix) EventPrefix() string {\n    return \"ABC\"\n}\n\nfunc (this TestEventPrefix) OnTestEvent(data any) {\n    fmt.Println(\"TestEventPrefix: \")\n    fmt.Println(data)\n}\n\ntype TestEventSubscribe struct {}\n\nfunc (this *TestEventSubscribe) Subscribe(e *event.Events) {\n    e.Listen(\"TestEventSubscribe\", this.OnTestEvent)\n}\n\nfunc (this *TestEventSubscribe) OnTestEvent(data any) {\n    fmt.Println(\"TestEventSubscribe: \")\n    fmt.Println(data)\n}\n\ntype TestEventStructData struct {\n    Data string\n}\n\nfunc TestEventStruct(data TestEventStructData, name any) {\n    fmt.Println(\"TestEventStruct: \")\n    fmt.Println(data.Data)\n    fmt.Println(name)\n}\n\ntype TestEventStructHandle struct {}\n\nfunc (this *TestEventStructHandle) Handle(data any) {\n    fmt.Println(\"TestEventStructHandle: \")\n    fmt.Println(data)\n}\n\nfunc main() {\n    // Listen\n    event.Listen(\"data.error\", func(data any) any {\n        fmt.Println(data)\n        return nil\n    })\n\n    // Dispatch\n    eventData := \"index data\"\n    event.Dispatch(\"data.error\", eventData)\n\n    // call prefix `data.` all listener\n    event.Dispatch(\"data.*\", eventData)\n\n    // ==================\n\n    // Subscribe struct\n    event.Subscribe(\u0026TestEvent{})\n    event.Subscribe(TestEventPrefix{})\n    event.Subscribe(\u0026TestEventSubscribe{})\n\n    // call listens\n    event.Dispatch(\"TestEvent\", eventData)\n    event.Dispatch(\"TestEventName\", eventData)\n    event.Dispatch(\"ABCTestEvent\", eventData)\n    event.Dispatch(\"TestEventSubscribe\", eventData)\n\n    // ==================\n\n    // listen struct data\n    event.Listen(TestEventStructData{}, TestEventStruct)\n\n    // call\n    eventData2 := \"index data\"\n    event.Dispatch(TestEventStructData{\n        Data: eventData2,\n    })\n\n    // ==================\n\n    // listen struct and use struct Handle func to call\n    event.Listen(\"TestEventStructHandle\", \u0026TestEventStructHandle{})\n\n    // call\n    event.Dispatch(\"TestEventStructHandle\", eventData)\n}\n\n~~~\n\n\n### LICENSE\n\n*  The library LICENSE is `Apache2`, using the library need keep the LICENSE.\n\n\n### Copyright\n\n*  Copyright deatil(https://github.com/deatil).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeatil%2Fgo-event","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeatil%2Fgo-event","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeatil%2Fgo-event/lists"}