{"id":27104366,"url":"https://github.com/producthunt/kittyevents","last_synced_at":"2025-06-14T16:33:50.893Z","repository":{"id":47008545,"uuid":"77337123","full_name":"producthunt/KittyEvents","owner":"producthunt","description":"Super simple event system on top of ActiveJob","archived":false,"fork":false,"pushed_at":"2022-07-28T07:20:56.000Z","size":31,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-06-08T23:47:46.978Z","etag":null,"topics":["activejob","events","rails","sidekiq"],"latest_commit_sha":null,"homepage":null,"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/producthunt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-25T18:00:39.000Z","updated_at":"2023-12-19T11:06:12.000Z","dependencies_parsed_at":"2022-09-13T18:13:39.428Z","dependency_job_id":null,"html_url":"https://github.com/producthunt/KittyEvents","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/producthunt/KittyEvents","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/producthunt%2FKittyEvents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/producthunt%2FKittyEvents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/producthunt%2FKittyEvents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/producthunt%2FKittyEvents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/producthunt","download_url":"https://codeload.github.com/producthunt/KittyEvents/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/producthunt%2FKittyEvents/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259845779,"owners_count":22920798,"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":["activejob","events","rails","sidekiq"],"created_at":"2025-04-06T17:32:57.084Z","updated_at":"2025-06-14T16:33:50.848Z","avatar_url":"https://github.com/producthunt.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :heart_eyes_cat: KittyEvents\n[![Gem Version](https://badge.fury.io/rb/kitty_events.svg)](https://badge.fury.io/rb/kitty_events) [![Build Status](https://travis-ci.org/producthunt/KittyEvents.svg?branch=master)](https://travis-ci.org/producthunt/KittyEvents)\n\nSuper simple event system built on top of ActiveJob.\n\nKittyEvents implements the [publish/subscribe](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern) pattern using ActiveJob. You setup your events and list the subscribers for them. When an event is triggered, KittyEvents will fanout the event to each of your subscribers.\n\n### Why use this\n- Uses ActiveJob. No need to add a new dependency for pub/sub.\n- Reduce complexity/establish patterns. Can be used to replace `after_commit`'s. This creates easier to follow/read code. Less surprises = good!\n- Replace several `perform_later`'s with a single event `trigger`. Reducing the amount of I/O happening in request (less I/O = faster response times)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'kitty_events'\n```\n\nAnd then execute:\n\n    $ bundle install\n\n## Usage\n\nIn Rails, setup your events and subscribers.\n\n```Ruby\nmodule ApplicationEvents\n  extend KittyEvents\n\n  event :user_signup, [\n    WelcomeEmailWorker,\n    WelcomeTweetWorker,\n    SyncProfileImageWorker,\n    ExampleWorker.set(wait: 5.minutes), # standard ActiveJob settings work as well!\n  ]\n\n  event :user_upvote, [\n    SomeWorker,\n    AnotherWorker,\n  ]\nend\n```\n\n*You can put this in `app/workers` or similar folder.*\n\nEach subscriber must be an ActiveJob and respond to `perform_later(object)`.\n\n```Ruby\nclass ExampleWorker \u003c ActiveJob::Base\n  def perform(user)\n    # do work\n  end\nend\n```\n\nThen in your application, to trigger an event. Do the following.\n\n```Ruby\nApplicationEvents.trigger(:user_signup, user)\n```\n\nUsing the above example, triggering this event would pass `user` to each of the subscribers defined in our initializer:\n```\nWelcomeEmailWorker,\nWelcomeTweetWorker,\nSyncProfileImageWorker,\nExampleWorker.set(wait: 5.minutes)\n```\n\n## Worker Configuration\nThe worker is configurable via the initializer. Here are examples for catching errors and setting the queue.\n\n```Ruby\n# config/initializers/application_events.rb\nmodule ApplicationEvents\n  extend KittyEvents\n\n  event :user_signup, [\n    WelcomeEmailWorker,\n    WelcomeTweetWorker,\n  ]\n\n  handle_worker.rescue_from ActiveJob::DeserializationError do |exception|\n    # handle deserialization errors\n  end\n\n  handle_worker.queue_as :events # use a specific queue\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/producthunt/kittyevents. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n\n## License\n\n[![Product Hunt](http://i.imgur.com/dtAr7wC.png)](https://www.producthunt.com)\n\n```\n _________________\n\u003c The MIT License \u003e\n -----------------\n        \\   ^__^\n         \\  (oo)\\_______\n            (__)\\       )\\/\\\n                ||----w |\n                ||     ||\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproducthunt%2Fkittyevents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fproducthunt%2Fkittyevents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproducthunt%2Fkittyevents/lists"}