{"id":15439167,"url":"https://github.com/maxbarsukov/rbminivents","last_synced_at":"2025-10-06T02:10:56.798Z","repository":{"id":40577927,"uuid":"357262403","full_name":"maxbarsukov/rbminivents","owner":"maxbarsukov","description":"📆 Tiny eventing gem","archived":false,"fork":false,"pushed_at":"2022-05-01T09:01:37.000Z","size":52,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-26T13:47:18.219Z","etag":null,"topics":["events","gem","gems","ruby","ruby-events","ruby-gem"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/maxbarsukov.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-12T16:22:05.000Z","updated_at":"2023-11-18T16:20:28.000Z","dependencies_parsed_at":"2022-08-09T23:40:33.257Z","dependency_job_id":null,"html_url":"https://github.com/maxbarsukov/rbminivents","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/maxbarsukov%2Frbminivents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbarsukov%2Frbminivents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbarsukov%2Frbminivents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbarsukov%2Frbminivents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxbarsukov","download_url":"https://codeload.github.com/maxbarsukov/rbminivents/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248231753,"owners_count":21069393,"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","gem","gems","ruby","ruby-events","ruby-gem"],"created_at":"2024-10-01T19:03:06.616Z","updated_at":"2025-10-06T02:10:51.767Z","avatar_url":"https://github.com/maxbarsukov.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rbminivents\n\n\u003e This gem allows you to easily use minimalistic events in Ruby.\n\n![rb.minvents logo](https://github.com/maxbarsukov/rbminivents/blob/master/docs/images/logo.png?raw=true)\n\n## Description\nThis gem was made under the influence of the tiny JS library [minivents](https://github.com/allouis/minivents) by [allouis](https://github.com/allouis) that I liked.\nIt seemed to me that it would be quite nice to move something like this to Ruby.\n\n## Getting started\n\n### Requirements\n\nThis gem requires Ruby 2.5+. It might work with older versions of Rails though.\n\n### Installation\n\nAdd the gem to your `Gemfile`:\n\n```ruby\ngem 'rbminivents'\n```\n\nand run:\n\n```\nbundle install\n```\n\n## API\nThis project is similar to the original one in many ways, but some features are not implemented. You can use standard ruby mixins for fully functionality. So,\n\n`on`: Listen to event. Returns handle\n\n`off`: Stop listening to event \n\n`emit`: Emit event\n\n\n## Examples\n### Standard way\n```ruby\nrequire 'rbminivents'\n\nsandbox = RbMinivents::Events.new\n\nsandbox.on(:event) do\n  # do stuff\nend\n\nsandbox.emit(:event)  # does stuff\n\nsandbox.off(:event)\n\nsandbox.emit(:event)  # does not do stuff\n```\n\n### Passing parameters\n```ruby\nrequire 'rbminivents'\n\nsandbox = RbMinivents::Events.new\n\nsandbox.on(:event) do |name|\n  puts \"Hello, #{name}!\"\nend\n\nsandbox.emit(:event, 'Max')  #=\u003e Hello, Max!\n```\n\n```ruby\nrequire 'rbminivents'\n\nsandbox = RbMinivents::Events.new\n\nsandbox.on(:event) do |hash, arr, num, bool|\n  puts hash[:name]\n  p arr\n  puts \"5 + #{num} = #{5 + num}\"\n  puts \"It's true!\" if bool\nend\n\n# max, [1, 2, 3], 5 + 7 = 12\nsandbox.emit(:event,\n             {name: 'max'},\n             [1, 2, 3],\n             7,\n             false\n)\n```\n\n### Using Off\n```ruby\nrequire 'rbminivents'\n\nsandbox = RbMinivents::Events.new\n\nhandler1 = sandbox.on(:event) do\n  puts \"First Hello!\"\nend\n\nhandler2 = sandbox.on(:event) do\n  puts \"Second Hello!\"\nend\n\n# remove just this callback\nsandbox.emit(:event)  # =\u003e First Hello!\\nSecond Hello!\n\nsandbox.off(:event, handler1)\nsandbox.emit(:event)  # =\u003e Second Hello!\n\nsandbox.off(:event, handler2)\nsandbox.emit(:event)  # =\u003e nothing...\n\n# re-add listener to show can remove all at once\nsandbox.on(:event) do\n  puts \"Hello!\"\nend\n\n# remove all\nsandbox.off(:event)\nsandbox.emit(:event)  # =\u003e nothing again\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxbarsukov%2Frbminivents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxbarsukov%2Frbminivents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxbarsukov%2Frbminivents/lists"}