{"id":20314349,"url":"https://github.com/normandy72/event-system","last_synced_at":"2026-04-29T23:33:26.517Z","repository":{"id":153902772,"uuid":"590834705","full_name":"Normandy72/Event-System","owner":"Normandy72","description":"AngularJS Event System. Coursera course \"Single Page Web Applications with AngularJS\" by Yaakov Chaikin.","archived":false,"fork":false,"pushed_at":"2023-01-19T10:24:07.000Z","size":112,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-04T20:56:23.564Z","etag":null,"topics":["angular","angularjs","css","css3","html","html5","javascript","js"],"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/Normandy72.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-01-19T10:22:50.000Z","updated_at":"2023-01-19T10:25:15.000Z","dependencies_parsed_at":"2023-05-06T16:47:31.058Z","dependency_job_id":null,"html_url":"https://github.com/Normandy72/Event-System","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Normandy72/Event-System","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FEvent-System","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FEvent-System/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FEvent-System/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FEvent-System/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Normandy72","download_url":"https://codeload.github.com/Normandy72/Event-System/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FEvent-System/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32448400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"ssl_error","status_checked_at":"2026-04-29T22:10:49.234Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","angularjs","css","css3","html","html5","javascript","js"],"created_at":"2024-11-14T18:14:53.553Z","updated_at":"2026-04-29T23:33:26.502Z","avatar_url":"https://github.com/Normandy72.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AngularJS Event System\n## Publish-Subscribe Design Pattern\nPublishers send messages to subscribers on a common channel.\n#### Publishers:\n* Mark messages with a classification.\n* Don't know subscribers or if there are any.\n#### Subscribers:\n* Sign up to listen for messages with a particular classification.\n* Don't know publishers or if there are any.\n\nIn Angular the common channel is __scope__.\n\nMessages are events that can hold data.\n## Publishing an Event\n* `$scope.$emit` - events go UP the scope chain.\n* `$scope.$broadcast` - events go DOWN the scope chain.\n* `$scope.$on`\n## Steps to create event\n#### Step 1: Broadcast or Emit an Event\n```\n$scope.$broadcast(\n    'namespace:eventName',\n    {prop: value}\n);\n```\nor\n```\n$scope.$emit(\n    'namespace:eventName',\n    {prop: value}\n);\n```\n`'namespace:eventName'` - name of event (note namespace)\n\n`{prop: value}` - data object to travel with event\n#### Step 2: Listen for \u0026 Handle the Event\n```\n$scope.$on('namespace:eventName', handler);\n\nfunction handler(event, data){\n    if(data.prop === 'val1')\n    {\n        ...\n    }\n};\n```\n`'namespace:eventName'` - same name as was emitted / broadcasted\n`data` and `data.prop` - data that traveled with the event\n\n***\n##### _Summary_\n* Publish-subscribe design pattern is implemented using the Angular Events system.\n* You can publish events from anywhere in the system and listen for those events anywhere in the system.\n* `$scope.$emit` sends the event up the scope chain.\n* `$scope.$broadcast` sends the event down the scope chain.\n* To broadcast to all nodes, use `$rootScope.$broadcast`.\n* To listen for event, use either `$scope.$on` or `$rootScope.$on`.\n* Deregister listener when using `$rootScope.$on`.\n***","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnormandy72%2Fevent-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnormandy72%2Fevent-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnormandy72%2Fevent-system/lists"}