Skip to content

feat(store): initialized$ #1575

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

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

feat(store): initialized$ #1575

wants to merge 1 commit into from

Conversation

rbalet
Copy link
Collaborator

@rbalet rbalet commented Jul 31, 2025

Description

I've noticed that we aren't waiting the httpLoader before doing any data mutation, this does create the following error:

Do

We're now waiting for the initialized$ to be triggered, before letting using use the set() method.
This later also has been transformed to a Promises, letting people be sure the value is set before moving forward (you can see this in the test).

Note

We could surely fix other problem with this logic, but I'd prefer to do small PRs

@CodeAndWeb
Copy link
Member

I don't think that this is the problem in the ticket. The big happens long after loading.
Users who want to set translations after loading some of them can use the subscription of use().

But it might be indeed useful to have a waitInitialized() observable. 👍

I don't want to make set() async. This adds complexity that is not required - other functions like instant() also require an initialized service. 👎

The issue described here is more related to this:
66964cf

@rbalet
Copy link
Collaborator Author

rbalet commented Aug 5, 2025

@CodeAndWeb I was able to reproduce the error in the ticket and the PR does solve the problem.

Here's the step to reproduce

  1. Inside the app.component.ts constructor, add a .set that override any value
  2. Inside a timeout of 100ms, get this value
  3. You'll see, the value is not the one you've just .set, but the one from the file

Why?
Because the file needs to be loaded, as the .set is called almost directly
When the i18n file load, it then replace the .set value

I understand this PR to be adding a bit of complexity, but I believe the user won't be impacted (outside the fact that they won't be facing this bug anymore).

But maybe you have a better idea on how to solve this issue.

(Or maybe the step to reproduce is noir pointing to the error I thought it was '^^)

Cheers

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