{"id":15490382,"url":"https://github.com/theodesp/sima","last_synced_at":"2025-04-06T03:26:11.763Z","repository":{"id":97066628,"uuid":"116711279","full_name":"theodesp/sima","owner":"theodesp","description":"Sima is a simple object to object or broadcast dispatching system for Go","archived":false,"fork":false,"pushed_at":"2018-01-14T13:14:57.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-19T09:17:46.598Z","etag":null,"topics":["broadcast-reciever","dispatcher","golang-library","object-to-object","signalling"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/theodesp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":"CONTRIBUTING","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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-08T18:12:33.000Z","updated_at":"2018-02-03T11:53:25.000Z","dependencies_parsed_at":"2023-05-29T17:00:39.530Z","dependency_job_id":null,"html_url":"https://github.com/theodesp/sima","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/theodesp%2Fsima","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fsima/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fsima/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fsima/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theodesp","download_url":"https://codeload.github.com/theodesp/sima/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247429514,"owners_count":20937685,"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":["broadcast-reciever","dispatcher","golang-library","object-to-object","signalling"],"created_at":"2024-10-02T07:20:51.456Z","updated_at":"2025-04-06T03:26:11.730Z","avatar_url":"https://github.com/theodesp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"sima\n---\n\u003ca href=\"https://godoc.org/github.com/theodesp/sima\"\u003e\n\u003cimg src=\"https://godoc.org/github.com/theodesp/sima?status.svg\" alt=\"GoDoc\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://opensource.org/licenses/MIT\" rel=\"nofollow\"\u003e\n\u003cimg src=\"https://img.shields.io/github/license/mashape/apistatus.svg\" alt=\"License\"/\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://travis-ci.org/theodesp/sima\" rel=\"nofollow\"\u003e\n\u003cimg src=\"https://travis-ci.org/theodesp/sima.svg?branch=master\" /\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://codecov.io/gh/theodesp/sima\"\u003e\n  \u003cimg src=\"https://codecov.io/gh/theodesp/sima/branch/master/graph/badge.svg\" /\u003e\n\u003c/a\u003e\n\nSima is a simple object to object or broadcast dispatching system. \nAny number of interested parties can subscribe to events. \nSignal receives can receive also signals from specific senders.\n\n## Installation\n```bash\n$ go get -u github.com/theodesp/sima\n```\n\n## Usage\n1. Create a topic factory and re-use it for all signals yo want to create:\n\n```go\ntf := NewTopicFactory()\nonStart := NewSima(tf)\nonEnd := NewSima(tf)\n```\n\n2. After you have created your signals, just connect handlers for a particular topic or not. If you don't specify a topic then the handler will be assigned a ALL topic that defaults as a broadcast address.\n```go\n// Subscribe to ALL\nonStart.Connect(func(context context.Context, sender *Topic) interface{} {\n\t\tfmt.PrintF(\"OnStart called from Sender %+v\", sender)\n    return sender\n\t}, \"\")\n\n// Subscribe to specific sender/topic\nonEnd.Connect(func(context context.Context, sender *Topic) interface{} {\n\t\tfmt.PrintF(\"onEnd called from Sender %+v\", sender)\n    return sender\n}, \"on-end-sender\")\n```\n\n3. Now just send some messages and any registered participant will call the handler.\n```go\nresponse := onStart.Dispatch(context.Background(), \"\") // will handle\nresponse := onStart.Dispatch(context.Background(), \"on-start-sender\") // will not handle\n\nresponse := onEnd.Dispatch(context.Background(), \"\") // will not handle\nresponse := onEnd.Dispatch(context.Background(), \"on-end-sender\") // will handle\n```\n\n* **Checking for receivers existance**\n```go\nonEnd.HasRecieversFor(\"on-end-sender\") // true\nonEnd.HasRecieversFor(\"on-start-sender\") // false\n```\n\n## LICENCE\nCopyright © 2017 Theo Despoudis MIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Fsima","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheodesp%2Fsima","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Fsima/lists"}