{"id":17669324,"url":"https://github.com/snimmagadda1/ng-reactive-snake","last_synced_at":"2025-03-30T13:43:57.945Z","repository":{"id":223716063,"uuid":"758189835","full_name":"snimmagadda1/ng-reactive-snake","owner":"snimmagadda1","description":"An implementation of the classic game snake in an angular web app... built reactively! ","archived":false,"fork":false,"pushed_at":"2024-02-21T16:08:01.000Z","size":2688,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T15:42:49.636Z","etag":null,"topics":["angular","javascript","reactive-programming","reactive-streams","rxjs","typescript","webdevelopment"],"latest_commit_sha":null,"homepage":"","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/snimmagadda1.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}},"created_at":"2024-02-15T19:54:08.000Z","updated_at":"2024-02-21T16:09:42.000Z","dependencies_parsed_at":"2024-02-21T18:40:16.223Z","dependency_job_id":null,"html_url":"https://github.com/snimmagadda1/ng-reactive-snake","commit_stats":null,"previous_names":["snimmagadda1/ng-reactive-snake"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snimmagadda1%2Fng-reactive-snake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snimmagadda1%2Fng-reactive-snake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snimmagadda1%2Fng-reactive-snake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snimmagadda1%2Fng-reactive-snake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snimmagadda1","download_url":"https://codeload.github.com/snimmagadda1/ng-reactive-snake/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246326600,"owners_count":20759436,"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":["angular","javascript","reactive-programming","reactive-streams","rxjs","typescript","webdevelopment"],"created_at":"2024-10-24T00:08:33.003Z","updated_at":"2025-03-30T13:43:57.918Z","avatar_url":"https://github.com/snimmagadda1.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ng Reactive Snakes\n\nThe classic game of snake! Built using reactive programming \u0026 angular:\n\n![Snake game gif](./snake.gif)\n\n## Why build this?\n\nThis is an exercise in thinking \u0026 programming reactively. The intent here is not to make a beautiful game, but rather expose the internals of how something like this can be built. This is a version of [this approach](https://blog.thoughtram.io/rxjs/2017/08/24/taming-snakes-with-reactive-streams.html) using modern RxJS\n\n## About the build\n\nThe game is driven by only a handful of source streams:\n\n| Source stream | Function | Code |\n|----------|----------|----------|\n| `tick$` | game clock interval that dictate snake pace | `interval(100)`  |\n| `direction$` | mapped output from KeyboardEvent listener | `fromEvent(document, 'keydown').pipe(startWith({ keyCode: 39 }),map(event =\u003e DIRECTIONS[(event as KeyboardEvent).keyCode]),filter(direction =\u003e !!direction),startWith(DIRECTIONS[37]),distinctUntilChanged());`  |\n| `snakeLength$` | accumulator to track the length of the snake | `this._length$.asObservable().pipe(scan((acc, length) =\u003e length + acc),share())`  |\n\n## Getting started\n\nThe simplest way to run is simply clone, install deps, \u0026 start up the angular dev server:\n\n```bash\ngit clone https://github.com/snimmagadda1/ng-reactive-snake.git\ncd ng-reactive-snake\nnpm install \nnpm run start\n```\n\nYou will be able to play the game and monitor key streams.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnimmagadda1%2Fng-reactive-snake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnimmagadda1%2Fng-reactive-snake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnimmagadda1%2Fng-reactive-snake/lists"}