Files
angular-challenges/docs/src/content/docs/challenges/angular/39-injection-token.md
2024-07-23 10:46:00 +02:00

1.4 KiB

title, description, author, contributors, challengeNumber, command, videoLinks, sidebar
title description author contributors challengeNumber command videoLinks sidebar
🟠 InjectionToken Challenge 39 is about learning the power of dependency injection thomas-laforge
tomalaforge
jdegand
LMFinney
39 angular-injection-token
link alt flag
https://www.youtube.com/watch?v=ntggdQycFyc Injection Token by Arthur Lannelucq FR
order
118

Information

In this small application, we start with a VideoComponent containing a 1-second timer. The development team decided to use a global constant to store the timer value: DEFAULT_TIMER. However, a few weeks later, the product team wants to add a new screen for phone calls called PhoneComponent, and we want to reuse the TimerComponent. However, the product team wants a timer of 2 seconds. How can we achieve this?

Statement

Currently, the timer is still 1 second for the PhoneComponent. The goal of this challenge is to change the timer value to 2 seconds for the PhoneComponent.

Constraints

The use of @Input is forbidden. This example is basic, and using @Input could be a good option, but in more complex applications, the component we need to update can be deeply nested, making the use of @Input a really bad design.

Hint

Hint 1

Looking at this blog post can be of great help.