{"id":17965906,"url":"https://github.com/pavan-kumar2/multinational-news-app","last_synced_at":"2026-04-12T00:03:50.451Z","repository":{"id":259274327,"uuid":"861186184","full_name":"pavan-kumar2/Multinational-News-App","owner":"pavan-kumar2","description":"Developed a comprehensive, mobile-responsive news browsing application using Angular and RxJS. This project empowers users to explore news articles by country, category, and source, with efficient data flow.","archived":false,"fork":false,"pushed_at":"2025-02-02T05:01:48.000Z","size":426,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T08:34:51.794Z","etag":null,"topics":["angular","css","css3","html","html5","javascript","nodejs","npm-package","responsive-website","rxjs","rxjs-observable","rxjs-subscriptions","sass","scss","typescript"],"latest_commit_sha":null,"homepage":"https://multinational-news-app.netlify.app","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/pavan-kumar2.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":"2024-09-22T08:29:41.000Z","updated_at":"2025-02-02T05:01:51.000Z","dependencies_parsed_at":"2024-12-16T23:13:02.252Z","dependency_job_id":"69b57533-df1d-46bb-b54e-a1577adc3c68","html_url":"https://github.com/pavan-kumar2/Multinational-News-App","commit_stats":{"total_commits":62,"total_committers":1,"mean_commits":62.0,"dds":0.0,"last_synced_commit":"23d2c1bc8742230f785ea8147f04f7e7ded0fc36"},"previous_names":["pavan-kumar2/multinational-news-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pavan-kumar2%2FMultinational-News-App","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pavan-kumar2%2FMultinational-News-App/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pavan-kumar2%2FMultinational-News-App/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pavan-kumar2%2FMultinational-News-App/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pavan-kumar2","download_url":"https://codeload.github.com/pavan-kumar2/Multinational-News-App/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247071229,"owners_count":20878640,"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","css","css3","html","html5","javascript","nodejs","npm-package","responsive-website","rxjs","rxjs-observable","rxjs-subscriptions","sass","scss","typescript"],"created_at":"2024-10-29T13:06:01.145Z","updated_at":"2025-09-16T09:35:11.808Z","avatar_url":"https://github.com/pavan-kumar2.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multinational News App\n\nMultinational News App\nThe Multinational News App is an Angular-based application that aggregates and displays news from various countries and sources. It leverages modern Angular components, services, and RxJS for state management to provide users with an up-to-date and intuitive news browsing experience.\n\n## Features\n\n- Browse news articles from multiple countries.\n- Filter news by categories and sources.\n- Real-time updates with RxJS for state management.\n- Mobile-responsive UI built using Angular components.\n- Standalone component architecture for better modularity.\n\n## Technologies\n\n- Angular (Standalone components)\n- RxJS for state management\n- TypeScript\n- Sass for styling with @mixin and variables\n- HTML5, CSS3 \u0026 SCSS\n- Node.js \u0026 npm\n\n## Styling and UI\n\nThe UI is styled using **Sass (SCSS)**, which allows for a more modular and maintainable codebase:\n\n- **Variables**: Variables are used to store theme-related values like colors, font sizes, and margins. This makes it easy to maintain a consistent design and adjust styles centrally.\n\n  ```scss\n  $color-1: #b1cee3;\n  background-color: $color-1;\n  ```\n\n- **Mixins**: Reusable styles are created using Sass mixins to avoid code duplication. These mixins are defined for common patterns like flex layouts, buttons, and responsive breakpoints.\n\n  ```scss\n  @mixin flex-box($direction: null, $align: null, $justify: null, $wrap: null, $gap: null) {\n    display: flex;\n    flex-direction: $direction;\n    align-items: $align;\n    justify-content: $justify;\n    flex-wrap: $wrap;\n    gap: $gap;\n  }\n\n  @include flex-box($direction: column, $justify: space-between, $gap: 20px);\n  ```\n\n## Reactive State Management and Error Handling Using RxJS\n\n1. **Reactive State Management with BehaviorSubjects**\n\n   - `isErrorSubject` and `isLoadingSubject` are `BehaviorSubjects` in `NewsApiService` used to manage and emit changes in loading and error states.\n   - These subjects help provide real-time feedback across the application by emitting new values whenever the loading or error status changes.\n\n2. **Observables for State Tracking**\n\n   - `isError$` and `isLoading$` are observables created from the subjects, ensuring consistent state updates across components.\n   - Components like `CardsComponent` can subscribe to these observables to track loading and error states without directly manipulating the `BehaviorSubjects`.\n\n3. **Data Transformation with RxJS Operators**\n\n   - **`map`**: This operator transforms incoming news article data, adding a fallback image for missing URLs and formatting the publish date using `getFormattedDate()`.\n   - **`tap`**: Used for side effects, such as updating loading and error statuses after data processing but before passing the data to subscribers.\n\n4. **Error Handling with `catchError`**\n\n   - Errors encountered during HTTP requests are managed by `catchError`, logging the error, updating the error state, and returning an empty array to avoid application crashes.\n\n5. **Subscription Management with `takeUntil`**\n   - In `CardsComponent`, `takeUntil` ensures that subscriptions are automatically unsubscribed when the component is destroyed. This is achieved through a `Subject` (`destroy$`), which signals to complete all observable streams on component teardown, preventing memory leaks.\n\n## Code Highlights\n\n```typescript\n// newsAPi service\nexport class NewsApiService {\n  private isErrorSubject: BehaviorSubject\u003cboolean\u003e = new BehaviorSubject\u003cboolean\u003e(false);\n  private isLoadingSubject: BehaviorSubject\u003cboolean\u003e = new BehaviorSubject\u003cboolean\u003e(false);\n\n  isError$: Observable\u003cboolean\u003e = this.isErrorSubject.asObservable();\n  isLoading$: Observable\u003cboolean\u003e = this.isLoadingSubject.asObservable();\n\n  constructor(private http: HttpClient) {}\n\n  getFormattedDate() {\n    const currentDate = new Date();\n    const formattedDate = currentDate.toLocaleDateString(\"en-CA\", { year: \"numeric\", month: \"2-digit\", day: \"2-digit\" });\n    const formattedTime = currentDate.toLocaleTimeString(\"en-US\", { hour12: true });\n    return `${formattedDate} \u003cspan\u003e${formattedTime}\u003c/span\u003e`;\n  }\n\n  getNewsRequest(country: string) {\n    this.isLoadingSubject.next(true);\n    return this.http.get\u003c{ articles: NewsArticle[] }\u003e(`https://example.com/news-${country}.json`).pipe(\n      map((response) =\u003e\n        response.articles.map((article) =\u003e ({\n          ...article,\n          urlToImage: article.urlToImage || \"assets/images/no-image-found.png\",\n          publishedAt: this.getFormattedDate(),\n        }))\n      ),\n      tap(() =\u003e {\n        this.isLoadingSubject.next(false);\n        this.isErrorSubject.next(false);\n      }),\n      catchError((error) =\u003e {\n        console.error(\"Error fetching news:\", error);\n        this.isLoadingSubject.next(false);\n        this.isErrorSubject.next(true);\n        return of([]);\n      })\n    );\n  }\n}\n\n// card component\nexport class CardsComponent implements OnInit, OnDestroy {\n  private destroy$ = new Subject\u003cvoid\u003e();\n\n  constructor(private newsApiService: NewsApiService) {}\n\n  ngOnInit() {\n    this.newsApiService.isLoading$.pipe(takeUntil(this.destroy$)).subscribe((value) =\u003e (this.isLoading = value));\n    this.newsApiService.isError$.pipe(takeUntil(this.destroy$)).subscribe((value) =\u003e (this.isError = value));\n  }\n\n  fetchNewsArticles(country: string) {\n    this.newsApiService\n      .getNewsRequest(country)\n      .pipe(takeUntil(this.destroy$))\n      .subscribe((value) =\u003e (this.newsArticles = value));\n  }\n\n  ngOnDestroy() {\n    this.destroy$.next();\n    this.destroy$.complete();\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpavan-kumar2%2Fmultinational-news-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpavan-kumar2%2Fmultinational-news-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpavan-kumar2%2Fmultinational-news-app/lists"}