Why won't a getter from a service/state work after any store changes?
See original GitHub issueHi there,
Just to clarify my understanding:
If you read: #using-observable-store-with-angular => Point 9, it says the following:
// Can call service/store to get data directly
// It won't fire when the store state changes though in this case
//this.storeSub = this.customersService.get().subscribe(custs => this.customers = custs);
I find that the following is indeed not working:
public getIsLoggedIn(): Observable<boolean> {
return this.stateChanged.pipe(switchMap((x) => of(x.isAuthenticated)));
}
Why isn’t it the case that when you call a get wrapper function that it won’t fire any subsequent, or even initial/last state changes?
Also here: #comment @DanWahlin says the following:
… Currently the store will send the latest state so I wanted to check on that part of your scenario there.
I’m thinking i’m missing some big part of the puzzle but I haven’t been able to figure it out.
Thank you for any answers!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Getters is not working and state value cannot be change in ...
$store.getters.semuaJasa , once I change the code using getters, it won't display in the browser. I can't change the value ...
Read more >Service Plugin - feathersjs-ecosystem/feathers-vuex
The makeServicePlugin method creates a vuex plugin which connects a Feathers service to the Vuex store. Once you create a plugin, you must...
Read more >Angular Service: State Management | Tutorial | Nisan Sabag
To keep track of the changes for this property, we will bound it to template of the component that use it with a...
Read more >Service Module API | FeathersVuex
The Service Module creates plugins which can be used to connect a Feathers service to the Vuex store. Once you create the plugin,...
Read more >Need more info regarding release update 'Validate Getter ...
For most subscribers, I suspect that no changes will be necessary. ... continue to work for their subscribers after the update is enabled....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@spierala, thanks for the answer!
I managed to solve it but the problem was unrelated to Observable Store.
I was making separate service classes, and some service classes had a dependency on others. My mistake was putting all those subscriptions in the constructor of each service class, which meant some subscriptions weren’t even setup to begin with.
I solved this by giving each service class a
setup()
function and then call each ‘service.setup()’ on app startup.Now everything works as perfectly!
Stupid mistake on my part.
I’m catching up on the thread (thanks for jumping in @spierala - appreciate that) but am glad you found the root of the problem @JasonLandbridge. I do something similar in my services where I need to initialize something. I call it
init
but it’s basically the same purpose as yoursetup
call.As far as the “stupid mistake on my part” comment, I can sympathize. I’ve made plenty of those mistakes myself. 😃