{"id":13509703,"url":"https://github.com/simonewebdesign/elixir_pubsub","last_synced_at":"2025-04-13T06:21:47.110Z","repository":{"id":33798771,"uuid":"37492016","full_name":"simonewebdesign/elixir_pubsub","owner":"simonewebdesign","description":":droplet: Publish/Subscribe utility module","archived":false,"fork":false,"pushed_at":"2025-04-10T16:58:26.000Z","size":73,"stargazers_count":69,"open_issues_count":1,"forks_count":11,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-13T05:00:05.899Z","etag":null,"topics":["elixir","pubsub"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/pubsub","language":"Elixir","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/simonewebdesign.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-15T21:21:39.000Z","updated_at":"2025-04-10T16:58:29.000Z","dependencies_parsed_at":"2024-01-05T21:59:56.874Z","dependency_job_id":"693bba09-85a8-47c0-a6e2-db5a81824354","html_url":"https://github.com/simonewebdesign/elixir_pubsub","commit_stats":{"total_commits":59,"total_committers":8,"mean_commits":7.375,"dds":"0.18644067796610164","last_synced_commit":"08919baccc941f5d486d35ccece32fd85b5fea43"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonewebdesign%2Felixir_pubsub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonewebdesign%2Felixir_pubsub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonewebdesign%2Felixir_pubsub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonewebdesign%2Felixir_pubsub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonewebdesign","download_url":"https://codeload.github.com/simonewebdesign/elixir_pubsub/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665756,"owners_count":21142123,"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":["elixir","pubsub"],"created_at":"2024-08-01T02:01:11.756Z","updated_at":"2025-04-13T06:21:47.087Z","avatar_url":"https://github.com/simonewebdesign.png","language":"Elixir","funding_links":[],"categories":["Utilities"],"sub_categories":[],"readme":"# Elixir Publish/Subscribe\n\n[![Build Status](https://app.travis-ci.com/simonewebdesign/elixir_pubsub.svg?branch=main)](https://app.travis-ci.com/simonewebdesign/elixir_pubsub) [![Coverage Status](https://coveralls.io/repos/github/simonewebdesign/elixir_pubsub/badge.svg?branch=main)](https://coveralls.io/github/simonewebdesign/elixir_pubsub?branch=main) [![Hex package](https://img.shields.io/hexpm/v/pubsub.svg)](https://hex.pm/packages/pubsub) [![Documentation](https://inch-ci.org/github/simonewebdesign/elixir_pubsub.svg?branch=main)](https://inch-ci.org/github/simonewebdesign/elixir_pubsub) [![Total Downloads](https://img.shields.io/hexpm/dt/pubsub.svg)](https://hex.pm/packages/pubsub)\n\nA Publish/Subscribe utility module that frees your business logic processes from the burden of communication.\n\n\n## Getting Started\n\nAdd `:pubsub` as a dependency to your `mix.exs` file:\n\n``` elixir\ndefp deps do\n  [\n    {:pubsub, \"~\u003e 1.0\"}\n  ]\nend\n```\n\nThen run `mix deps.get` in your shell to fetch the dependencies.\n\n\n## Examples\n\nAssuming your client process looks like this:\n\n``` elixir\ndefmodule Client do\n\n  def start(client_name) do\n    spawn(fn -\u003e loop(client_name) end)\n  end\n\n  def loop(name) do\n    receive do\n      message -\u003e\n        IO.puts \"#{name} received `#{message}`\"\n        loop(name)\n    end\n  end\n\nend\n```\n\nWith `PubSub` you can do this:\n\n``` elixir\niex(1)\u003e {topic1, topic2} = {:erlang, :elixir}\n{:erlang, :elixir}\n\niex(2)\u003e {:ok, pid} = PubSub.start_link()\n{:ok, #PID\u003c0.99.0\u003e}\n\niex(3)\u003e {pid1, pid2, pid3} =\n...(3)\u003e {\n...(3)\u003e Client.start(\"John\"),\n...(3)\u003e Client.start(\"Nick\"),\n...(3)\u003e Client.start(\"Tim\")\n...(3)\u003e }\n{#PID\u003c0.106.0\u003e, #PID\u003c0.107.0\u003e, #PID\u003c0.108.0\u003e}\n\niex(4)\u003e PubSub.subscribe(pid1, topic1)\n:ok\niex(5)\u003e PubSub.subscribe(pid2, topic1)\n:ok\niex(6)\u003e PubSub.subscribe(pid3, topic2)\n:ok\n\niex(7)\u003e PubSub.publish(topic1, \"#{topic1} is great!\")\n\"Nick received `erlang is great!`\"\n\"John received `erlang is great!`\"\n:ok\n\niex(8)\u003e PubSub.publish(topic2, \"#{topic2} is so cool, dude\")\n\"Tim received `elixir is so cool, dude`\"\n:ok\n```\n\n## API Reference\n\nhttps://hexdocs.pm/pubsub/PubSub.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonewebdesign%2Felixir_pubsub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonewebdesign%2Felixir_pubsub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonewebdesign%2Felixir_pubsub/lists"}