Skip to content
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

Answer:39 injection token #1172

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

apalaio
Copy link

@apalaio apalaio commented Jan 11, 2025

No description provided.

@github-actions github-actions bot added 39 injection token DI answer answer sponsor sponsor the project to be reviewed PR requests a review labels Jan 11, 2025
export const DEFAULT_TIMER = 1000;
import { InjectionToken, ValueProvider } from '@angular/core';

export const TIMER = new InjectionToken<number>('default-timer');
Copy link
Owner

Choose a reason for hiding this comment

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

that's good, but you can be even better by using the factory function inside the InjectionToken class, so you can provide a default value and you only have to override it when needed.

@tomalaforge tomalaforge removed the to be reviewed PR requests a review label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
39 injection token DI answer answer sponsor sponsor the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants