I want to populate my initialState in signalStore from a backend API call.
When I do this via the OnInit hook, I get a false emission of my ‘real’ initialState that I configured using withState. I want to use the factory function approach as outlined in the documents so that the return from the API is hte only initialState that my store emits. I can’t find a complete example though.
- In the factory function how do I handle an async call that returns an observable? The withState method seems to expect a representation of my state not an observable?
- Can I architect this in such a way as to allow my population logic to also be callable from within my WithMethods methods so I can do a refresh of my store as required?
Thanks