By: @BTroncone
Also check out my lesson @ngrx/store in 10 minutes on egghead.io!
Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!
Table of Contents
import {List, Record, toJS} from 'immutable'; | |
import Rx, {Observable, Subject} from 'rx'; | |
const initialState = Record({count: 0, text: '', items: List(), history: List(), future: List()}); | |
const subject = new Subject(); | |
const source = Observable.merge(subject) | |
.scan((currentState, action) => action(currentState), initialState()); | |
source.subscribe( | |
state => { |
By: @BTroncone
Also check out my lesson @ngrx/store in 10 minutes on egghead.io!
Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!
Table of Contents
A complete list of RxJS 5 operators with easy to understand explanations and runnable examples.
Say we have a store defined as follows:
export class Store {
Facades are a programming pattern in which a simpler public interface is provided to mask a composition of internal, more-complex, component usages.
When writing a lot of NgRx code - as many enterprises do - developers quickly accumulate large collections of actions and selectors classes. These classes are used to dispatch and query [respectively] the NgRx Store.
Using a Facade - to wrap and blackbox NgRx - simplifies accessing and modifying your NgRx state by masking internal all interactions with the Store
, actions
, reducers
, selectors
, and effects
.
For more introduction, see Better State Management with Ngrx Facades
/** | |
* When manually subscribing to an observable in a view component, developers are traditionally required | |
* to unsubscribe during ngOnDestroy. This utility method auto-configures and manages that relationship | |
* by watching the DOM with a MutationObserver and internally using the takeUntil RxJS operator. | |
* | |
* Angular 7 has stricter enforcements and throws errors with monkey-patching of view component life-cycle methods. | |
* Here is an updated version that uses MutationObserver to accomplish the same goal. | |
* | |
* @code | |
* |
{ | |
"index": "/index.html", | |
"appData": { | |
"version": "1.1.0", | |
"changelog": "Added better resource caching" | |
}, | |
"assetGroups": [ | |
{ | |
"name": "shell", | |
"installMode": "prefetch", |