Skip to content

refactor: simplify example component #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2024

Conversation

ptu14
Copy link
Contributor

@ptu14 ptu14 commented Sep 5, 2024

Simplify and Improve Angular Counter Component

Overview

This PR simplifies the Angular counter component, improving its readability and code formatting while maintaining its core functionality.

Changes Made

  1. Component Structure Simplification

    • Removed unnecessary properties and methods
    • Streamlined the component class structure
  2. Template Cleanup

    • Simplified the component's template
  3. Code Formatting

    • Improved overall code formatting for better readability
    • Standardized import statements

Example of Updated Component

import { Component } from '@angular/core'
import { injectSelector, injectDispatch } from "@reduxjs/angular-redux";
import { decrement, increment } from './store/counter-slice'
import { RootState } from './store'

@Component({
  selector: 'app-root',
  standalone: true,
  template: `
    <button (click)="dispatch(increment())">
      Increment
    </button>
    <span>{{ count() }}</span>
    <button (click)="dispatch(decrement())">
      Decrement
    </button>
  `
})
export class AppComponent {
  count = injectSelector((state: RootState) => state.counter.value)
  dispatch = injectDispatch()
  increment = increment
  decrement = decrement
}

I apologize for any confusion caused by the previous PR. Due to a force push, the earlier PR has been closed, and this new PR replaces it with a simplified version of the Angular counter component.

Copy link
Member

@crutchcorn crutchcorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@crutchcorn crutchcorn merged commit a796124 into reduxjs:main Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants