{"id":15394242,"url":"https://github.com/xyproto/event2","last_synced_at":"2025-03-27T23:44:03.468Z","repository":{"id":57532410,"uuid":"232617292","full_name":"xyproto/event2","owner":"xyproto","description":"Simple time-based event system, for triggering events at HH:MM","archived":false,"fork":false,"pushed_at":"2020-03-30T11:54:23.000Z","size":20,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-02T01:46:24.354Z","etag":null,"topics":["events","eventsystem","go"],"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/xyproto.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}},"created_at":"2020-01-08T17:17:21.000Z","updated_at":"2020-06-02T07:34:09.000Z","dependencies_parsed_at":"2022-09-26T16:50:31.256Z","dependency_job_id":null,"html_url":"https://github.com/xyproto/event2","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fevent2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fevent2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fevent2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fevent2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xyproto","download_url":"https://codeload.github.com/xyproto/event2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245944062,"owners_count":20697948,"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":["events","eventsystem","go"],"created_at":"2024-10-01T15:22:44.015Z","updated_at":"2025-03-27T23:44:03.447Z","avatar_url":"https://github.com/xyproto.png","language":"Go","readme":"# Event II\n\n[![Build Status](https://travis-ci.com/xyproto/event2.svg?branch=master)](https://travis-ci.com/xyproto/event2) [![GoDoc](https://godoc.org/github.com/xyproto/event2?status.svg)](https://godoc.org/github.com/xyproto/event2) [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/xyproto/event2/master/LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/xyproto/event2)](https://goreportcard.com/report/github.com/xyproto/event2)\n\nA simple event system, for triggering events at certain times. This is the successor of [event](https://github.com/xyproto/event), which was needlessly complex.\n\n## Example use\n\n**Leet o'clock**\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/xyproto/event2\"\n)\n\nfunc main() {\n\t// Create a new event system, with a loop iteration delay of 1 second\n\teventSys := event2.NewSystem(1 * time.Second)\n\t// Add an event that will trigger every day at 13:37\n\teventSys.ClockEvent(13, 37, func() error {\n\t\tfmt.Println(\"It's leet o'clock\")\n\t\treturn nil\n\t})\n\t// Run the event system (not verbose)\n\teventSys.Run(false)\n\t// Wait endlessly\n\tvar wg sync.WaitGroup\n\twg.Add(1)\n\twg.Wait()\n}\n```\n\n**Clock**\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/xyproto/event2\"\n)\n\nfunc clockSystem() *event2.EventSys {\n\tsys := event2.NewSystem(1 * time.Second)\n\tfor hour := 0; hour \u003c 24; hour++ {\n\t\tfor minute := 0; minute \u003c 60; minute++ {\n\t\t\t// Create new variables that can be closed over by the new function below\n\t\t\thour := hour\n\t\t\tminute := minute\n\t\t\t// Create a new event that will trigger at the specified hour and minute\n\t\t\tsys.ClockEvent(hour, minute, func() error {\n\t\t\t\tfmt.Printf(\"The clock is %02d:%02d\\n\", hour, minute)\n\t\t\t\treturn nil\n\t\t\t})\n\t\t}\n\t}\n\treturn sys\n}\n\nfunc main() {\n\t// Start the event system that will trigger an event at every minute\n\tclockSystem().Run(false)\n\t// Wait endlessly while saying \"tick\" and \"tock\" every second\n\tfor {\n\t\tfmt.Println(\"tick\")\n\t\ttime.Sleep(1 * time.Second)\n\t\tfmt.Println(\"tock\")\n\t\ttime.Sleep(1 * time.Second)\n\t}\n}\n```\n\n## General info\n\n* Version: 0.0.1\n* License: MIT\n* Author: Alexander F. Rødseth \u0026lt;xyproto@archlinux.org\u0026gt;\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyproto%2Fevent2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxyproto%2Fevent2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyproto%2Fevent2/lists"}