{"id":15405577,"url":"https://github.com/krisleech/wisper_next","last_synced_at":"2025-10-18T11:34:13.067Z","repository":{"id":66255586,"uuid":"213375412","full_name":"krisleech/wisper_next","owner":"krisleech","description":"The next version of Wisper [MIRROR]","archived":false,"fork":false,"pushed_at":"2019-11-07T12:17:38.000Z","size":88,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T04:44:47.490Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://gitlab.com/kris.leech/wisper_next","language":"Ruby","has_issues":false,"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/krisleech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-07T12:19:06.000Z","updated_at":"2020-03-13T17:12:12.000Z","dependencies_parsed_at":"2023-02-20T21:30:56.026Z","dependency_job_id":null,"html_url":"https://github.com/krisleech/wisper_next","commit_stats":{"total_commits":40,"total_committers":1,"mean_commits":40.0,"dds":0.0,"last_synced_commit":"bba4ce446fbfe13e4d37adfbc092bf3d174feaec"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fwisper_next","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fwisper_next/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fwisper_next/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fwisper_next/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krisleech","download_url":"https://codeload.github.com/krisleech/wisper_next/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245359248,"owners_count":20602322,"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-10-01T16:17:13.204Z","updated_at":"2025-10-18T11:34:08.044Z","avatar_url":"https://github.com/krisleech.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WisperNext\n\nThis is the next version of Wisper. Alpha only.\n\n## Installation\n\n```ruby\ngem 'wisper_next'\n```\n\n## Usage\n\n### Publishing\n\n```ruby\nclass MyPublisher\n  include WisperNext.publisher\n\n  def call\n    broadcast(:wow, x: rand(10), y: rand(10), at: Time.now)\n  end\nend\n```\n\nA publisher can broadcast events, the first argument is the event name followed\nby an optional payload.\n\n### Listeners\n\n#### Objects\n\n```ruby\nclass MyListener\n  def on_event(event_name, payload)\n    puts \"#{event_name} received with #{payload.inspect}\"\n  end\nend\n```\n\nWe can then subscribe an instance of our listener to the publisher:\n\n```ruby\npublisher = MyPublisher.new\npublisher.subscribe(MyListener.new)\npublisher.call\n```\n\n#### Blocks\n\nBlocks can be subscribed to a specific event name.\n\n```ruby\npublisher = MyPublisher.new\npublisher.on(:wow) { |payload| puts(payload) }\npublisher.call\n```\n\n### Enhanced Listeners\n\nBy including `Wisper.subscriber` you can get additional features.\n\nFirstly instead of `#on_event` you provide a method for every event the\nlistener may receive. For example if our publisher broadcasts a \"user_created\"\nevent then the listener would provide a `user_created` method which receives\nthe payload.\n\n```ruby\nclass MyListener\n  include Wisper.subscriber\n  \n  def user_created(payload)\n    #...\n  end\nend\n```\n\nIf the listener receives an event for which there is no method an exception\nis raised.\n\nYou can opt-out of this behaviour by setting the `strict` option to false:\n\n```ruby\ninclude Wisper.subscriber(strict: false)\n```\n\n#### Prefixing broadcast events\n\nThe method called can be prefixed with `on_`:\n\n```ruby\nclass MyListener\n  include Wisper.subscriber(prefix: true)\n  \n  def on_user_created(payload)\n    #...\n  end\nend\n```\n\n#### Handling Events Asynchronously\n\nWisperNext has adapters for asynchronous event handling, please refer to\n\u003cTODO\u003e.\n\n```ruby\ninclude Wisper.subscriber(async: :true)\n```\n\nIf you are interested in building an async adapter and releasing it as a gem\nplease get in touch.\n\n#### Passing options\n\nIf the value for an option being passed to subscriber is `true` then you can\nuse a symbol instead to mean the same thing.\n\nSo `WisperNext.subscriber(async: true)` and `WisperNext.subscriber(:async)` are\nthe same. You can pass multiple symbols with any key/values at the end,\ne.g. `WisperNext.subscriber(:async, :prefix, strict: false)`.\n\n### Global Subscriptions\n\n```ruby\nEVENTS = WisperNext::Events.new\n\nEVENTS.subscribe(MyListener.new)\n\nEVENTS.broadcast('user_promoted', user: user)\n```\n\n## Security\n\n* gem releases are [signed](https://gitlab.com/kris.leech/wisper_next/blob/master/keys/gem-public_cert.pem)\n* commits are GPG [signed](https://gitlab.com/kris.leech/wisper_next/blob/master/keys/kris.leech.gpg.public)\n\n## Development\n\n## Contributing\n\nBug reports and pull requests are welcome on Gitlab at https://gitlab.com/kris.leech/wisper_next.\n\nThis 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## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the WisperNext project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/kris.leech/wisper_next/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrisleech%2Fwisper_next","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrisleech%2Fwisper_next","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrisleech%2Fwisper_next/lists"}