Closed TomPridham closed 7 years ago
Why dont you just inject the store into the service where you require it? :confused:
What would that look like?
Im not entirely sure if u can directly inject the store instance into a service. You should try. If not, you could try to configurate a custom factoryMethod for the service that depends on the store. See here for the second
@TomPridham are you using the TestBed? If so, just provide the TestBed.configureModule with the StoreModule.provideStore(reducer)
, then you get can get the instance of the store using TestBed.get(Store)
Sorry for the late reply, I'm just getting back to implementing these tests. That put me on the right track, Brandon.
I ended up doing imports:[StoreModule.provideStore(rootReducer, defaultState)]
Thanks for the help!
I'm trying to test a service that has an ngrx store injected by Angular's injector. I'm not clear on how to actually inject a store by hand. Everything I've seen goes into injecting ngrx into a component with a module.
All I want to do is something like
new service(someDependency, new Store(reducers, defaultState))
, but Typescript complains that the signature doesn't match. What is the correct way to do this?Thanks.