Replies: 1 comment 6 replies
-
TDLR; of above : how do you inject initial state into stores? .. if its not possible , why not?.. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
so i am creating a factory service for "lightweight" signal stores.
each store has unique domain logic so each attached to its own component provider. domain entities are only known at runtime via a websocket.
As runtime creation of components is frowned upon in the angular community .. not to mention the hacky code involved.
My approach therefore is to predefine a max pool of 12 components each with a signal store and lazy route load the components at runtime as needed.
I am using a provider factory service with my domain logic so i can than add the initialState for the store when its created.
The problem i am finding is that i don't know how to inject initial state into the store while its created..
The way i am doing it, is first create the store then call a function to patch the state with the initialization data. I guess this is ok..
it doesn't feel great.
eg:
i type the store using:
and then in my Storefactory when called by the component provider useFactory (addInitialState is under withMethods)
would be great if i could do :
return new ProfileStore({initialState: domain_logic_mapped_to_URL_segment})
suggestions welcome to this approach
Beta Was this translation helpful? Give feedback.
All reactions