{"id":24360210,"url":"https://github.com/sqlprovider/angular2-pubsub","last_synced_at":"2025-08-17T01:33:15.841Z","repository":{"id":57179688,"uuid":"81454613","full_name":"sqlProvider/angular2-pubsub","owner":"sqlProvider","description":"Publisher/Subscriber service for Angular 2","archived":false,"fork":false,"pushed_at":"2017-11-29T12:12:00.000Z","size":34,"stargazers_count":10,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-11T22:54:58.961Z","etag":null,"topics":["angular","angular2","angular2-service","angular4","angular4-service","pubsub"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/sqlProvider.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.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":"2017-02-09T13:48:01.000Z","updated_at":"2018-07-24T12:59:14.000Z","dependencies_parsed_at":"2022-09-10T23:56:58.594Z","dependency_job_id":null,"html_url":"https://github.com/sqlProvider/angular2-pubsub","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/sqlProvider/angular2-pubsub","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlProvider%2Fangular2-pubsub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlProvider%2Fangular2-pubsub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlProvider%2Fangular2-pubsub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlProvider%2Fangular2-pubsub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqlProvider","download_url":"https://codeload.github.com/sqlProvider/angular2-pubsub/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlProvider%2Fangular2-pubsub/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270796220,"owners_count":24647319,"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","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["angular","angular2","angular2-service","angular4","angular4-service","pubsub"],"created_at":"2025-01-18T21:04:20.634Z","updated_at":"2025-08-17T01:33:15.820Z","avatar_url":"https://github.com/sqlProvider.png","language":"TypeScript","readme":"# Pub/Sub Service for Angular 2\n\nA simple publisher/subscriber service. \n\n[![NPM](https://nodei.co/npm/angular2-pubsub.png?downloads=true\u0026stars=true)](https://nodei.co/npm/angular2-pubsub/)\n\n## Usage\n - Import service in your codes or download via npm or bower.\n\n`npm i --save angular2-pubsub`\n\n\tif you use Angular version 2.x.x plase install from npm with '2.0.6' tag.\n\n`npm i --save angular2-pubsub@2.0.6`\n\n - Add module bundle to imports in your application.\n```typescript\n...\n\nimport { PubSubModule } from 'angular2-pubsub'; // \u003c= HERE\n\n@NgModule({\ndeclarations: [\n\tRootComponent,\n\tNavigationComponent,\n\tOverlayComponent\n],\nimports: [\n\tBrowserModule,\n\tFormsModule,\n\tHttpModule,\n\tPubSubModule.forRoot() // \u003c= AND HERE\n],\nproviders: [], \nbootstrap: [RootComponent]\n})\n\n...\n```\n - And import service wherever you want\n\n## Documentation\n\n#### Class Overview\n\n```typescript\ndeclare class PubSubService {\n\tprivate events: Object;\n\t$pub(event: string, eventObject?: any): void;\n\t$sub(): undefined;\n\t$sub(event: string): Observable\u003cany\u003e;\n\t$sub(event: string, callback: (value: any) =\u003e void): Subscription;\n\t$sub(event: string, callback: (value: any) =\u003e void, error: (error: any) =\u003e void): Subscription;\n\t$sub(event: string, callback: (value: any) =\u003e void, error: (error: any) =\u003e void, complete: () =\u003e void): Subscription;\n}\n```\n\n#### PubSubService.$pub(event: string, eventObject?: any): void\n\t\nPublish event to all subscriber.\n\netc.\n```typescript\nexport class OverlayComponent implements OnInit, OnDestroy {\n\tconstructor(private pubsub: PubSubService) { }\n\n\tanyFunc(){\n\t\tthis.pubsub.$pub('pleaseCloseSidenav', 'helloIAmOverlay');\n\t}\n}\n```\n\n#### PubSubService.$sub(event: string): Observable\u003cany\u003e\n\nSubscribe to channel. \n\netc.\n```typescript\nexport class NavigationComponent implements OnInit, OnDestroy {\n\tsideanvSub: any;\n\t\n\tconstructor(private pubsub: EventDispatcherService) { }\n\n\tngOnInit() {\n\t\t// usage of $sub(event: string): \u003cObservable\u003cany\u003e\u003e;\n\t\tthis.closeSidenavSub = this.pubsub.$sub('pleaseCloseSidenav').subscribe((from) =\u003e {\n\t\t\tthis.sidenavOpened = false;\n\t\t});\n\n\t\t// usage of $sub(event: string, callback: (value: any) =\u003e void, error?: (error: any) =\u003e void, complete?: () =\u003e void): Subscription;\n\t\tthis.openSidenavSub = this.pubsub.$sub('pleaseOpenSidenav', (from) =\u003e {\n\t\t\tthis.sidenavOpened = true;\n\t\t});\n\t}\n\tngOnDestroy() {\n\t\tthis.closeSidenavSub.unsubscribe();\n\t\tthis.openSidenavSub.unsubscribe();\n\t}\n```\n\n**See Changelog** ~~$sub method have one bug. RxJS Subscriber call subscribe method on start like Angular 1.x $scope.$watch.~~\n\n## Build the source\n\nFollow the steps to run the tests and build the source code.\n```sh\nnpm install\nnpm test\nnpm run build\n```\nCommands above will generate the ready to use bundles under the `./dist` folder.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlprovider%2Fangular2-pubsub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqlprovider%2Fangular2-pubsub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlprovider%2Fangular2-pubsub/lists"}