{"id":20461061,"url":"https://github.com/ericgj/bus","last_synced_at":"2025-10-30T17:43:47.327Z","repository":{"id":8343435,"uuid":"9901946","full_name":"ericgj/bus","owner":"ericgj","description":"A simple, declarative event bus component for typical cases.","archived":false,"fork":false,"pushed_at":"2013-05-07T19:20:22.000Z","size":148,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T11:34:16.120Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericgj.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-07T02:10:57.000Z","updated_at":"2013-10-19T21:53:37.000Z","dependencies_parsed_at":"2022-08-07T03:00:29.703Z","dependency_job_id":null,"html_url":"https://github.com/ericgj/bus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ericgj/bus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Fbus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Fbus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Fbus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Fbus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericgj","download_url":"https://codeload.github.com/ericgj/bus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Fbus/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259518830,"owners_count":22870303,"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-11-15T12:23:02.567Z","updated_at":"2025-10-30T17:43:42.291Z","avatar_url":"https://github.com/ericgj.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Bus\n\n  A simple, declarative event bus for typical cases.\n  \n  AKA a fluid DSL on top of Emitter.\n\n## Installation\n\n    $ component install ericgj/bus\n\n## Example\n\n```javascript\n  var bus = require('bus')();\n\n  var mainPanel = MainPanel('#main');\n  var sidePanel = SidePanel('#sidebar');\n  var filterPanel = FilterPanel('#filter');\n\n  logFilterEvent = function(param) {\n    console.log('filter: %s', param);\n  }\n\n  /**\n   *  Route 'select' events from the filterPanel to\n   *  mainPanel.applyFilter and sidePanel.setFilter,\n   *  and to two custom handlers\n   */\n  bus.route().from(filterPanel, 'select')\n     .to( mainPanel, 'applyFilter' )\n     .to( sidePanel, 'setFilter' )\n     .handle( logFilterEvent )\n     .handle( function(param) { /* some callback */ } );\n\n  /**\n   *  Or, define routes in reverse direction. Here\n   *  events from sidePanel and mainPanel are routed\n   *  to filterPanel.clearFilter.\n   */\n  bus.route().to(filterPanel, 'clearFilter')\n     .from( sidePanel, 'reset' )\n     .from( mainPanel, 'clear' );\n\n  /**\n   *  You can define different routes in a single call\n   *  using route(), aliased as reset()\n   */\n  bus.route()\n       .from(x,'event')\n         .to(y1,'method')\n         .to(y2,'method')\n     .reset()\n       .to(z,'method')\n         .from(w1,'event')\n         .from(w2,'event');\n\n```\n\n## API\n\n### Bus#from(source, event)\n\nSet the current source. If a receiver has been set, then bind the event to it.\n\n### Bus#to(receiver, method)\n\nSet the current receiver. If a source has been set, then bind its event to \nthe receiver.\n\n### Bus#handle(fn)\n\nSet the current receiver to an arbitrary function rather than object + method.\n\n### Bus#route or #reset\n\nReset the current source and receiver, to define a new route.\n   \n## Note\n\nThere are no hard dependencies, any `emitter`-ish object (with `.on`) will work\nas a source.\n\nThe DSL does not currently control unbinding events (`.off`), so if you want \nthat, manage it in your sources, or send me a pull request for \n`bus.off().to().from()`  :wink:\n\n## License\n\n  MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericgj%2Fbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericgj%2Fbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericgj%2Fbus/lists"}