Главная | Actual Topics | Обратная связь | В избранное | Сделать домашней | Антиспам ;)
 System & Utilities
 Unix News
 OS Emulator
Каталог статей
Все статьи

Биллу Гейтсу тоже предлагают избавиться ...
Вымогательство в борьбе со спамом

December, 2018
Какой из этих ОС Вы отдаете большее предпочтение?

Mac OS
Windows XP
Windows 2003
Что такое ОС? :)

Другие опросы

Всего голосов: 327
Комментарии: 0

Архив Новостей
 December 2018 (4)
 November 2018 (7)
 October 2018 (13)
 September 2018 (8)
 August 2018 (8)
 July 2018 (11)
 June 2018 (13)
 May 2018 (10)
 April 2018 (14)
 March 2018 (11)
 February 2018 (13)
 January 2018 (13)
 December 2017 (14)
 November 2017 (15)
 October 2017 (19)
 September 2017 (18)
 August 2017 (13)
 February 2017 (14)
 January 2017 (19)
 December 2016 (16)
 November 2016 (16)
 October 2016 (21)
 September 2016 (18)
 August 2016 (16)
 July 2016 (16)
 June 2016 (20)
 May 2016 (18)
 April 2016 (15)
 March 2016 (22)
 February 2016 (17)
 January 2016 (15)
 December 2015 (15)
 November 2015 (22)
 October 2015 (20)
 September 2015 (17)
 August 2015 (25)
 July 2015 (20)
 June 2015 (23)
 May 2015 (21)
 April 2015 (17)
 March 2015 (19)
 February 2015 (9)
 January 2015 (23)
 December 2014 (9)
 November 2014 (13)
 October 2014 (12)
 September 2014 (18)
 August 2014 (20)
 July 2014 (10)
 June 2014 (12)
 May 2014 (12)
 April 2014 (10)
 March 2014 (22)
 February 2014 (10)
 January 2014 (8)
 December 2013 (26)
 November 2013 (53)
 October 2013 (40)
 September 2013 (48)
 August 2013 (63)
 July 2013 (56)
 June 2013 (52)
 May 2013 (49)
 April 2013 (67)
 March 2013 (74)
 February 2013 (63)
 January 2013 (62)
 December 2012 (62)
 November 2012 (66)
 October 2012 (68)
 September 2012 (48)
 August 2012 (75)
 July 2012 (60)
 June 2012 (71)
 May 2012 (69)
 April 2012 (85)
 March 2012 (86)
 February 2012 (90)
 January 2012 (81)
 December 2011 (103)
 November 2011 (118)
 October 2011 (74)
 September 2011 (2)
 June 2011 (110)
 May 2011 (118)
 April 2011 (111)
 March 2011 (112)
 February 2011 (101)
 January 2011 (119)
 December 2010 (117)
 November 2010 (118)
 October 2010 (131)
 September 2010 (117)
 August 2010 (226)
 July 2010 (351)
 June 2010 (305)
 May 2010 (319)
 April 2010 (343)
 March 2010 (329)
 February 2010 (311)
 January 2010 (312)
 December 2009 (266)
 November 2009 (156)
 July 2009 (101)
 June 2009 (279)
 May 2009 (365)
 April 2009 (348)
 March 2009 (347)
 February 2009 (323)
 January 2009 (318)
 December 2008 (237)
 November 2008 (155)
 October 2008 (334)
 September 2008 (310)
 August 2008 (343)
 July 2008 (362)
 June 2008 (322)
 May 2008 (456)
 April 2008 (1276)
 March 2008 (1658)
 February 2008 (250)
 January 2008 (6)
 November 2007 (1)
 September 2007 (1)
 June 2007 (1)
 May 2007 (1)
 March 2007 (1)
 January 2007 (2)
 December 2006 (1)
 October 2006 (2)
 September 2006 (1)
 August 2006 (2)

NGRX Store and State Management

System & Utilities

I have seen a couple of times experienced developers finding NGRX difficult to grasp. That was my experience as well. So I'll try to explain what it is about.

This is a great chat site for getting assistance. The angular/angular chat is active as well.

The best was to start is to lay out the problem that it solves. The Redux pattern implemented in NGRX is a way to maintain application state.

What is application state? All the data that the application requires to build and render the view over time.

Starting from the view, or Component level in Angular, here is how the data is presented by NGRX.

   selector: 'article-view',
   template: `<div ngfor="let a of articlelist$ | async">
export class ArticleListView {
   articlelist$ =;

   constructor(private store: Store) {}

First you inject the store using the constructor.
Then you assign a value with a selector, in this example, getArticles.

Then in the template articlelist$, an observable is piped through async, returning an array, passed to ngFor which loops through each item and displays the author and title.

State is a list of articles each with a title and author.

export interface Article {
   author: string;
   title: string;

export interface ArticleState {
   articlelist: Article[];

Then define that application state

export interface State {
   articles: ArticleState;

You may hit the first objection to this pattern right here. All you have is a list of objects, why the excessive boilerplate? Believe me it will get worse. In fact for such a simple application, NGRX doesn't really make sense. But fill out this example into a full content display application with users, multiple data sources, complex content structures, multiple developers. Then the boilerplate, the very clear definition of everything in a way that is easy to read becomes very important. Embrace the Boilerplate!

Adding a second state slice will help illustrate the pattern.

export interface State {
    articles: ArticleState;
    auth: AuthState;
    preferences: PreferencesState;

Authentication and authorization, and a way to track preferences are added to the State. I won't define them here for brevity's sake, but it will help you understand the Store structure when it comes to initialization.

A basic rule of this pattern is that the state is changed in one way only, with a reducer function. The function that looks like this:

export function reducer(state, action) {}

It gets passed state and an action. Here are the reducer functions for the three state slices.

export function articlesreducer(state: ArticleState = InitialArticleState, action: Action) {}

export function authreducer(state: AuthState = InitialAuthState, action: Action) {}

export function preferencesreducer(state: PreferencesState = InitialPreferenceState, action: Action) {}

Here with types. As you can see, the articlesreducer doesn't get State as a parameter, but State.articles. How does that work? This is how you define your reducers.

export const reducers: ActionReducerMap<State> = {
   articles: articlesreducer,
   auth: authreducer,
   preferences: preferencesreducer

Then to initialize the state, in your app.module.ts file

imports: [

The reducers object and the State interface properties match. When a reducer is called, the auth reducer is called with State.auth.

In the reducer function, if state is undefined it is assigned the value of the default. On initialization all reducers are called with an undefined state, initializing the state on startup.

What about that selector used in the component? Selectors are composed of a series of selectors that extract a specific property from the State.

export const getArticleState = (state: State) => state.articles;
export const getArticleList = (state: ArticleState) => state.articlelist;
export const getArticles = createSelector(getArticleState, getArticleList);

More boilerplate. Why not something like this?

export const getArticles = (state: State) => state.articles.articlelist;

Because every time any changes happen in State, the subscription in your component would fire.

This is one way of the two way data flows in the NGRX pattern. But it shows promise. A change in the state values will show up in the view. The data acquisition and handling is outside of the component. The Store structure is extensible, adding another state slice breaks nothing, making adding a feature to your app or component almost trivial.

How do you modify State? See here.
How do you break down the State into pieces that are modular?
How do you deal with api calls to get data from elsewhere? Here

For a suggestion on how to layout the files and folder structure, ngrx/example-app auth implementation


Разместил: Planet KDE | Дата: 04.09.2017 | Прочитано: 262 | Раздел: System & Utilities   

Рейтинг статьи

Средняя оценка: 0.00/0Средняя оценка: 0Всего голосов:0

Хорошо Нормально Пойдёт Плохо

Смотрите также связанные темы

16.05.2011 New Articles Published for Week Ending 5/14/11
New Articles Published for Week Ending 5/14/11 VMware ACE Applying a policy update package in ACE fails with the error: Setup has detected that this ACE package requires a newer version of VMware Workstation (1038992) Date Published: 5/9/2011 VMware Converter Converting a physical or virtual machine with VMware Converter takes longer than expected (1038454) Date Published: 5/12/2011 Starting a virtual machine that was converted using VMware Converter fails with the error: STOP 0x79 MISMATCHED_HAL (1038576) Date Published: 5/11/2011 Unable to log in to a Windows virtual machine after it h...
15.10.2008 Peet’s Coffee & Tea, Inc. Chooses VMware, Inc. Virtualization Platform
Specialty Coffee and Tea Company Deploys VMware Platform to Support Its Integrated Systems and Roast- to- Order Commitment to Customers. PALO ALTO, Calif. / EMERYVILLE, Calif. – October 14, 2008 —VMware, Inc. (NYSE: VMW), the global leader in virtualization solutions from the desktop to the datacenter, today announced that Peet’s Coffee & Tea, Inc. (Nasdaq: PEET), the premier specialty coffee and tea company in the U.S., has deployed VMware Infrastructure 3 and VMware Stage Manager to create a scalable, efficient and reliable platform for enterprise resource planning (ERP), store-level invento...
15.02.2010 Top 5 Planet V12n blog posts week 06
Top 5 Planet V12n blog posts week 06 VMware PEX 2010 was great... but it did mean I was extremely busy and didn't have time to create the top-5. I just picked the 5 best reads this week. Check it out: Jason Boche - My VCDX defense experienceThe first 75 minutes is spent “defending” my design.  I’ve got about a 15 slide deck to get through and to use as reference throughout the design defense.  I’d highly recommend putting as much reference as you can in the slide deck which you can yourself refer to during the defense.  It will help illustrate design choices and jog y...
06.06.2013 New Version of QNX CAR Platform Expands Design Choices to Include Android Apps and Qt User Interfaces
"Enables automotive companies to tap into vast ecosystem of mobile developers creating Android, HTML5, OpenGL ES, and Qt appsDETROIT, Telematics Detroit Conference, June 5, 2013 QNX Software Systems Limited, a global leader in software platforms for in-car electronics, today demonstrated how the new version of its QNX CAR Platform for Infotainment will enable developers of car infotainment systems to leverage an even broader choice of mobile apps and content.The QNX CAR Platform already supports both HTML5 and OpenGL ES, the two most popular open standards for mobile app development. With the ...
31.01.2011 New Articles Published for Week ending 1/29/2011
New Articles Published for Week ending 1/29/2011 VI SDK Recommended values in the soapAction field when forming Soap Requests for vSphere API (1033447) Date Published: 1/27/2011 VMware ACE Connecting a second mouse or keyboard directly to a hosted virtual machine (1033435) Date Published: 1/24/2011 VMware Data Recovery VdrFileRestore fails to run on Linux based operating systems (1033645) Date Published: 1/27/2011 VMware ESX Cannot create an additional disk on a different datastore on ESX while restoring the virtual machine (1030790) Date Published: 1/24/2011 Booting the Red Hat Enterprise ...
17.04.2011 Accessing your business contacts
Companies often store their customer information in databases managed by customer relation management tools.
25.04.2011 New Articles Published for week ending 4/23/11
New Articles Published for week ending 4/23/11 VMware ESX Installing and upgrading VMware Tools fails with the error: An error occurred while trying to access image file /usr/lib/vmware/isoimages/linux.iso (1037405) Date Published: 4/20/2011 Viewing performance data from vSphere Client fails with a HostCtl Exception (1037671) Date Published: 4/21/2011 The Windows virtual machine with VMware Tools reports Event ID 105 in the Event Viewer tab (1037755) Date Published: 4/18/2011 Powering on a virtual machine from a suspend state or reverting to a snapshot fails (1038218) Date Published: 4/20/...
07.05.2011 Top 5 Planet V12N blog posts for week 18
Top 5 Planet V12N blog posts for week 18 The VMware community is a unique social community with lots of collaboration, and people consistently trying to help each other out.  I think this makes this social circle more unique than some other social media circles out there.  For example check out the first blog post by Jason Boche, he has offered up his own lab infrastructure and bandwidth for anyone to test the VMware View iPad client.  Very cool! A couple of people have asked me how do I select the 5 blog posts for the week.  Giving back to the community is one of the qu...
30.05.2011 New Articles Published for Week Ending 5/28/11
New Articles Published for Week Ending 5/28/11 VMware ESX Cannot enable EVC in a cluster that has IBM blades (1000545) Date Published: 5/26/2011 Reinstalling the vpxa or aam agent without losing the host record from the vCenter Server database (1031919) Date Published: 5/26/2011 Accessing the vSphere Client Help fails when using Google Chrome as the default browser (1037183) Date Published: 5/24/2011 After running diskpart.exe to extend the disk size in Windows, the partition size does not get updated (1000630) Date Published: 5/23/2011 Troubleshooting issues when creating or committing sn...
06.06.2011 New Articles Published for Week Ending 6/4/11
New Articles Published for Week Ending 6/4/11 Grails What is the authority to export Grails and Grails plugins? (2000210) Date Published: 6/3/2011 Which Grails plugins are supported by SpringSource? (2000287) Date Published: 6/3/2011 VMware Capacity Planner Improving Capacity Planner Consolidation Ratio (1000256) Date Published: 6/1/2011 VMware Converter Converting a SUSE machine fails with the error: Converter.fault.HelperVmConnectionToSourceFault (1039312) Date Published: 5/30/2011 Cannot log in to a P2V converted Windows 2000 virtual machine (2000280) Date Published: 6/3/2011 VMware...
Нет комментариев. Почему бы Вам не оставить свой?
Вы не можете отправить комментарий анонимно, пожалуйста зарегистрируйтесь.
Google Search


Топ Новостей
1: Fedora and KDE/spin\'s treatment - Discussion
Просмотров - 3101

2: Offline Vaults for an extra layer of protection
Просмотров - 775

3: KDE\'s Kirigami 2.0 Framework for Convergent UIs Enters Beta with New Features
Просмотров - 755

4: Akonadi/KMail issues on Tumbleweed?
Просмотров - 681

5: Netrunner Desktop 16.09 "Avalon" Linux OS Is Out with Kernel 4.7, KDE Plasma 5.7
Просмотров - 657

6: Debugging issues booting a PC in 2018
Просмотров - 655

7: KDevelop 5.0.2 released for Windows and Linux
Просмотров - 641

8: plib3.gui 0.9.9
Просмотров - 625

9: Konstruct
Просмотров - 613

10: Best Desktop Environment
Просмотров - 597

11: KDE Connect – State of the union
Просмотров - 594

12: KDE Connect Sprint
Просмотров - 590

13: Come dine with the KDE e.V. board in Berlin in October
Просмотров - 589

14: Help Canonical Test GNOME Patches, Android Apps Illegally Tracking Kids, MySQL 8.0 Released and More
Просмотров - 581

15: Multi-screen woes in Plasma 5.7
Просмотров - 580

Google 120X240

Главная | Actual Topics | Статьи | Обратная связь | Guest Book
Генерация: 1.557 сек. и 13 запросов к базе данных за 1.505 сек.
Powered by SLAED CMS © 2005-2007 SLAED. All rights reserved.