When using Angular dependency injection, you have the ability to inject a string, function, or object by using a token instead of a service class.
To declare it in my module, I do this:
providers: [{ provide: MyValueToken, useValue: 'my title value'}]
and then I can use it like this:
constructor(@Inject(MyValueToken) my_value: string) {
this.title = my_value;
}
But how can I update the value from the component and have other components always receive the new value? Essentially, I want to mimic the functionality of a BehaviorSubject
to emit and receive values.
If achieving this is not possible, then what is the purpose of these injection tokens providing static data, when I could simply declare the static value in my component and use it directly?