Why use NGRX instead of constructor injected services?

泪湿孤枕 提交于 2019-12-05 08:22:45

You will need to write a service that provides a consistent and easy to change api to modify the data, you will need to come up with a fast and well tested way of querying the data, you will need to write and maintain observables for all your data. You will have to write and establish a pattern for async calls. You will have to write an api to access the data in your templates.

By the time you are done you will end up with something resembling ngrx.

For a simple one service data, ngrx is overkill, lots of boilerplate, but for a reactive app with multiple data sources or complex data interactions across numerous developers having a well used library is really helpful.

Follow SO answer for more in depth explanation: What are benefits of using store (ngrx) in angular 2

To understand, when to use which approach, read this: RxJs and Ngrx Store - When to Use a Store And Why?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!