An open API service indexing awesome lists of open source software.

https://github.com/leolanese/angular-component-communication

Angular (19+) Observables and Signal using @Input/@Output playground and Signal Input/Output
https://github.com/leolanese/angular-component-communication

angular httpresource observable rxjs signal typescript

Last synced: about 2 months ago
JSON representation

Angular (19+) Observables and Signal using @Input/@Output playground and Signal Input/Output

Awesome Lists containing this project

README

          

# Angular (19+) Observables Vs Signal using @Input/@Output playground and Signal Input/Output πŸ”Š

## Demo

![Demo](./src/app/assets/demo-updated.png)

---

## Modern practices latest final signal-based API is implementing πŸš€

```js
βœ… @NgModule β†’ Standalone component
βœ… *ngFor, *ngIf β†’ Modern control flow: @if, @for
βœ… Parent emits updates through writableSignal() following the Modern `Signal-Based Component Architecture Pattern` (Service (Shared State) ←→ Parent (Local State) ←→ Child (Pure Input))
βœ… ngOnInit() + subscribe() + contructor based inject β†’ Use reactive Signals + computed()
βœ… contruct-based DI injection β†’ inject(HttpClient)
βœ… Better Ts notation β†’ Protected + readonly template properties for protection and mutability control
βœ… Two-Way Binding (Old Way) β†’ signal-input-pattern
```

---

## NOTES:
> When passing values from a P -> C component using the `@Input`, `these values are not available in the constructor` = Avoids running Angular-specific logic or accessing @Input properties, as they are not yet set.

> If you need to react to changes in @Input values beyond initialization, consider using the `ngOnChanges()` lifecycle hook

### constructor()
- Called first, before any Angular lifecycle hooks.
- Used to initialise the component instance.
- Runs before Angular has fully initialized the component.
- `Not safe access @Input values`

### ngOnInit()
- called after the constructor, after the first ngOnChanges()
- `Safe for access @Input` values
- Runs after the constructor and after Angular sets up the component's bindings.

---

### :100: Thanks!
#### Now, don't be an stranger. Let's stay in touch!


leolanese’s GitHub image

##### :radio_button: Linkedin: LeoLanese
##### :radio_button: Twitter: @LeoLanese
##### :radio_button: DEV.to: Blog
##### :radio_button: Questions / Suggestion / Recommendation: developer@leolanese.com