{"id":21424103,"url":"https://github.com/gaeqs/hey","last_synced_at":"2025-03-16T20:42:02.865Z","repository":{"id":259149379,"uuid":"876250302","full_name":"gaeqs/Hey","owner":"gaeqs","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-05T14:09:21.000Z","size":882,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-23T07:13:29.240Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gaeqs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-10-21T16:44:05.000Z","updated_at":"2024-12-05T14:09:25.000Z","dependencies_parsed_at":"2024-10-23T02:29:17.710Z","dependency_job_id":null,"html_url":"https://github.com/gaeqs/Hey","commit_stats":null,"previous_names":["gaeqs/hey"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaeqs%2FHey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaeqs%2FHey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaeqs%2FHey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaeqs%2FHey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaeqs","download_url":"https://codeload.github.com/gaeqs/Hey/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243933374,"owners_count":20370988,"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":[],"created_at":"2024-11-22T21:19:36.220Z","updated_at":"2025-03-16T20:42:02.842Z","avatar_url":"https://github.com/gaeqs.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# _Hey!_ A C++20 Observer-Listener Library\n\n_Hey!_ is a lightweight and flexible observer-listener library built with modern C++20, designed to simplify the process\nof reacting to events through listeners. The core feature of Hey! are Observables, which allows objects to emit\nevents that registered listeners can respond to.\n\n_Hey!_ also can be used to listen value changes using the `Value` class. This class is ideal for situations where you\nneed to track changes to a value and notify listeners whenever the value is updated.\n\nFor more advance uses, _Hey!_ also implements the `DerivedValue` class. The value provided by these types of objects are\nderived from other values.\n\n## Examples:\n\n### Basic usage\n\n```c++\nhey::Observable\u003cint\u003e observable;\nhey::Listener\u003cint\u003e listener = [](int i) {\n    std::cout \u003c\u003c \"I received the value \" \u003c\u003c i \u003c\u003c \"!\" \u003c\u003c std::endl;\n};\nobservable += listener; // Or observable.addListener(listener)\nobservable.invoke(42); // Listener will be invoked.\nobservable -= listener; // Or observable.removeListener(listener)\nobservable.invoke(42); // Listener won't be invoked.\nobservable += listener;\nobservable += listener;\nobservable.invoke(42); // Listener will be invoked twice.\n```\n\n### Values\n\n```c++\nhey::ObservableValue\u003cint\u003e observable = 30;\n\nhey::Listener\u003cint\u003e listener = [](int i) {\n    std::cout \u003c\u003c \"I received the value \" \u003c\u003c i \u003c\u003c \"!\" \u003c\u003c std::endl;\n};\n\nobservable += listener; // Or observable.addListener(listener)\nobservable = 42; // Listener will be invoked.\n\nstd::cout \u003c\u003c \"Now the object holds the value \" \u003c\u003c observable.getValue() \u003c\u003c \".\" \u003c\u003c std::endl;\n\nobservable -= listener; // Or observable.removeListener(listener)\n\nobservable = 10; // Listener won't be invoked.\n\nstd::cout \u003c\u003c \"Now the object holds the value \" \u003c\u003c observable.getValue() \u003c\u003c \".\" \u003c\u003c std::endl;\n\nobservable += listener;\nobservable += listener;\nobservable = 60; // Listener will be invoked twice.\nstd::cout \u003c\u003c \"Now the object holds the value \" \u003c\u003c observable.getValue() \u003c\u003c \".\" \u003c\u003c std::endl;\n```\n\n### Derived values\n\n```c++\nhey::ObservableValue\u003cint\u003e a = 30;\nhey::ObservableValue\u003cint\u003e b = 5;\n\nhey::DerivedValue\u003cint, int, int\u003e c([](int a, int b) {\n    return a + b;\n}, a, b);\n\n\nhey::Listener\u003cint\u003e aListener = a.createListener([](int i) {\n    std::cout \u003c\u003c \"A = \" \u003c\u003c i \u003c\u003c \".\" \u003c\u003c std::endl;\n});\n\nhey::Listener\u003cint\u003e bListener = b.createListener([](int i) {\n    std::cout \u003c\u003c \"B = \" \u003c\u003c i \u003c\u003c \".\" \u003c\u003c std::endl;\n});\n\nhey::Listener\u003cint\u003e cListener = c.createListener([](int i) {\n    std::cout \u003c\u003c \"C = \" \u003c\u003c i \u003c\u003c \".\" \u003c\u003c std::endl;\n});\n\nstd::cout \u003c\u003c \"--- Initial values ---\" \u003c\u003c std::endl;\nstd::cout \u003c\u003c \"A = \" \u003c\u003c a.getValue() \u003c\u003c \".\" \u003c\u003c std::endl;\nstd::cout \u003c\u003c \"B = \" \u003c\u003c b.getValue() \u003c\u003c \".\" \u003c\u003c std::endl;\nstd::cout \u003c\u003c \"C = \" \u003c\u003c c.getValue() \u003c\u003c \".\" \u003c\u003c std::endl;\nstd::cout \u003c\u003c \"----------------------\" \u003c\u003c std::endl;\n\na = 10; // Calls aListener and cListener.\nb = 40; // Calls bListener and cListener.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaeqs%2Fhey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaeqs%2Fhey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaeqs%2Fhey/lists"}