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

"Store.name" creates duplicates once published #20

Closed
gerardomaranan opened this issue May 11, 2022 · 3 comments · Fixed by #25
Closed

"Store.name" creates duplicates once published #20

gerardomaranan opened this issue May 11, 2022 · 3 comments · Fixed by #25

Comments

@gerardomaranan
Copy link

gerardomaranan commented May 11, 2022

Newbie here!

Once code has been published some SomeStore.name are possibly duplicated and causes issue on hydrateStores.

Noticed this while creating multiple IStore classes. The app keeps getting stuck on splash screen in Production mode and failing at hydrateStores, and then I tried logging store each store loop iteration under said method and noticed t is being hydrated multiple times hence failing to hydrate one or more stores properply. The same code works fine in dev mode (probably because names aren't minified here).

Am I doing something wrong? Or any configurations I might've missed?


Worked around the issue by hard-coding name instead of using Function.name.

From:

export class SampleStore implements IStore {
  
   ...
  
    makePersistable(this, {
      name: SampleStore.name,
      properties: ['someProperty'],
    });

  ...

To:

    makePersistable(this, {
      name: "SampleStore",
      properties: ['someProperty'],
    });
@kanzitelli
Copy link
Owner

Hey @gerardomaranan! That's quite strange, I've never faced anything similar before. Are you sure that you are giving different names to store classes and changing it also in makePersistable? Because FooClass.name should always return the name of the class and if they are all different, makePersistable should work fine.

@gerardomaranan
Copy link
Author

Hey @kanzitelli, yup I'm pretty sure I named the store classes differently as it'll throw errors if I do not. I'll try and replicate it on a new project. I'll let you know. Thanks!

@kanzitelli
Copy link
Owner

@gerardomaranan yep, that would be great! Initially, it was implemented as a pure string as you mentioned in the question.

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 a pull request may close this issue.

2 participants