ajitsinghkaler / devto-clone

This is a dev to clone in angular. Where we used Angular component-store, rx-angular/template
https://dev-toclone.firebaseapp.com/
MIT License
39 stars 11 forks source link

Do we need store for all api #23

Open ajitsinghkaler opened 3 years ago

ajitsinghkaler commented 3 years ago

In this repo we are adding store for all API but do we need to add that. The data is not reused you can directly call the api and it should work. why add a store layer

fyodorio commented 3 years ago

Store is a kinda opinionated mental model. And not a bad one. It allows to separate concerns of actions (or updaters in this case, as you use Component Store), effects (which aren't just server events but also modal windows, error catching, logging, and other side stuff), and observable selectors, which can be reused widely (with memoization, that's important) instead of creating new subjects (or anything similar) in each API consuming component.

So if you like such approach (I mean, you started to use it from the beginning, hadn't you) it's great to stick with this solid, well-documented and well-tested solution.

But it's definitely up to you (and/or other maintainers).

ajitsinghkaler commented 3 years ago

Yeah but as I'm using it I think I use the API one time. Te store is used for nothing. We need store if we are reusing data in some way but I'm fetching data once showing it once. So, I'm starting to feel I need not store it in anyway. Component store is a service with a subject. I would not have even used service with a subject for all this

fyodorio commented 3 years ago

Well that makes sense. Anyway, if you don't see any use of the stores in future and you feel much more comfortable without them, why not get rid of it. It's always the matter of personal preference. I personally agree with an opinion of a great guy Armen Vardanyan who says something like "if an application is large enough for Angular, it's large enough for NgRx" 😄

In this case it's not the question of size but rather a tool choice though.