UNPKG

64 kBJavaScriptView Raw
1import { Injectable, InjectionToken, Inject, isDevMode, NgZone, NgModule, Optional, SkipSelf, Injector } from '@angular/core';
2import { BehaviorSubject, Observable, Subject, queueScheduler } from 'rxjs';
3import { observeOn, withLatestFrom, scan, pluck, map, distinctUntilChanged } from 'rxjs/operators';
4
5/**
6 * @fileoverview added by tsickle
7 * Generated from: src/globals.ts
8 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
9 */
10/** @type {?} */
11const REGISTERED_ACTION_TYPES = {};
12/**
13 * @return {?}
14 */
15function resetRegisteredActionTypes() {
16 for (const key of Object.keys(REGISTERED_ACTION_TYPES)) {
17 delete REGISTERED_ACTION_TYPES[key];
18 }
19}
20
21/**
22 * @fileoverview added by tsickle
23 * Generated from: src/action_creator.ts
24 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
25 */
26/**
27 * \@description
28 * Creates a configured `Creator` function that, when called, returns an object in the shape of the `Action` interface.
29 *
30 * Action creators reduce the explicitness of class-based action creators.
31 *
32 * \@usageNotes
33 *
34 * **Declaring an action creator**
35 *
36 * Without additional metadata:
37 * ```ts
38 * export const increment = createAction('[Counter] Increment');
39 * ```
40 * With additional metadata:
41 * ```ts
42 * export const loginSuccess = createAction(
43 * '[Auth/API] Login Success',
44 * props<{ user: User }>()
45 * );
46 * ```
47 * With a function:
48 * ```ts
49 * export const loginSuccess = createAction(
50 * '[Auth/API] Login Success',
51 * (response: Response) => response.user
52 * );
53 * ```
54 *
55 * **Dispatching an action**
56 *
57 * Without additional metadata:
58 * ```ts
59 * store.dispatch(increment());
60 * ```
61 * With additional metadata:
62 * ```ts
63 * store.dispatch(loginSuccess({ user: newUser }));
64 * ```
65 *
66 * **Referencing an action in a reducer**
67 *
68 * Using a switch statement:
69 * ```ts
70 * switch (action.type) {
71 * // ...
72 * case AuthApiActions.loginSuccess.type: {
73 * return {
74 * ...state,
75 * user: action.user
76 * };
77 * }
78 * }
79 * ```
80 * Using a reducer creator:
81 * ```ts
82 * on(AuthApiActions.loginSuccess, (state, { user }) => ({ ...state, user }))
83 * ```
84 *
85 * **Referencing an action in an effect**
86 * ```ts
87 * effectName$ = createEffect(
88 * () => this.actions$.pipe(
89 * ofType(AuthApiActions.loginSuccess),
90 * // ...
91 * )
92 * );
93 * ```
94 * @template T, C
95 * @param {?} type Describes the action that will be dispatched
96 * @param {?=} config Additional metadata needed for the handling of the action. See {\@link createAction#usage-notes Usage Notes}.
97 *
98 * @return {?}
99 */
100function createAction(type, config) {
101 REGISTERED_ACTION_TYPES[type] = (REGISTERED_ACTION_TYPES[type] || 0) + 1;
102 if (typeof config === 'function') {
103 return defineType(type, (/**
104 * @param {...?} args
105 * @return {?}
106 */
107 (...args) => (Object.assign(Object.assign({}, config(...args)), { type }))));
108 }
109 /** @type {?} */
110 const as = config ? config._as : 'empty';
111 switch (as) {
112 case 'empty':
113 return defineType(type, (/**
114 * @return {?}
115 */
116 () => ({ type })));
117 case 'props':
118 return defineType(type, (/**
119 * @param {?} props
120 * @return {?}
121 */
122 (props) => (Object.assign(Object.assign({}, props), { type }))));
123 default:
124 throw new Error('Unexpected config.');
125 }
126}
127/**
128 * @template P
129 * @return {?}
130 */
131function props() {
132 return { _as: 'props', _p: (/** @type {?} */ (undefined)) };
133}
134/**
135 * @template C
136 * @param {?} creators
137 * @return {?}
138 */
139function union(creators) {
140 return (/** @type {?} */ (undefined));
141}
142/**
143 * @template T
144 * @param {?} type
145 * @param {?} creator
146 * @return {?}
147 */
148function defineType(type, creator) {
149 return Object.defineProperty(creator, 'type', {
150 value: type,
151 writable: false,
152 });
153}
154
155/**
156 * @fileoverview added by tsickle
157 * Generated from: src/actions_subject.ts
158 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
159 */
160/** @type {?} */
161const INIT = (/** @type {?} */ ('@ngrx/store/init'));
162class ActionsSubject extends BehaviorSubject {
163 constructor() {
164 super({ type: INIT });
165 }
166 /**
167 * @param {?} action
168 * @return {?}
169 */
170 next(action) {
171 if (typeof action === 'function') {
172 throw new TypeError(`
173 Dispatch expected an object, instead it received a function.
174 If you're using the createAction function, make sure to invoke the function
175 before dispatching the action. For example, someAction should be someAction().`);
176 }
177 else if (typeof action === 'undefined') {
178 throw new TypeError(`Actions must be objects`);
179 }
180 else if (typeof action.type === 'undefined') {
181 throw new TypeError(`Actions must have a type property`);
182 }
183 super.next(action);
184 }
185 /**
186 * @return {?}
187 */
188 complete() {
189 /* noop */
190 }
191 /**
192 * @return {?}
193 */
194 ngOnDestroy() {
195 super.complete();
196 }
197}
198ActionsSubject.decorators = [
199 { type: Injectable }
200];
201/** @nocollapse */
202ActionsSubject.ctorParameters = () => [];
203/** @type {?} */
204const ACTIONS_SUBJECT_PROVIDERS = [ActionsSubject];
205
206/**
207 * @fileoverview added by tsickle
208 * Generated from: src/tokens.ts
209 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
210 */
211/** @type {?} */
212const _ROOT_STORE_GUARD = new InjectionToken('@ngrx/store Internal Root Guard');
213/** @type {?} */
214const _INITIAL_STATE = new InjectionToken('@ngrx/store Internal Initial State');
215/** @type {?} */
216const INITIAL_STATE = new InjectionToken('@ngrx/store Initial State');
217/** @type {?} */
218const REDUCER_FACTORY = new InjectionToken('@ngrx/store Reducer Factory');
219/** @type {?} */
220const _REDUCER_FACTORY = new InjectionToken('@ngrx/store Internal Reducer Factory Provider');
221/** @type {?} */
222const INITIAL_REDUCERS = new InjectionToken('@ngrx/store Initial Reducers');
223/** @type {?} */
224const _INITIAL_REDUCERS = new InjectionToken('@ngrx/store Internal Initial Reducers');
225/** @type {?} */
226const STORE_FEATURES = new InjectionToken('@ngrx/store Store Features');
227/** @type {?} */
228const _STORE_REDUCERS = new InjectionToken('@ngrx/store Internal Store Reducers');
229/** @type {?} */
230const _FEATURE_REDUCERS = new InjectionToken('@ngrx/store Internal Feature Reducers');
231/** @type {?} */
232const _FEATURE_CONFIGS = new InjectionToken('@ngrx/store Internal Feature Configs');
233/** @type {?} */
234const _STORE_FEATURES = new InjectionToken('@ngrx/store Internal Store Features');
235/** @type {?} */
236const _FEATURE_REDUCERS_TOKEN = new InjectionToken('@ngrx/store Internal Feature Reducers Token');
237/** @type {?} */
238const FEATURE_REDUCERS = new InjectionToken('@ngrx/store Feature Reducers');
239/**
240 * User-defined meta reducers from StoreModule.forRoot()
241 * @type {?}
242 */
243const USER_PROVIDED_META_REDUCERS = new InjectionToken('@ngrx/store User Provided Meta Reducers');
244/**
245 * Meta reducers defined either internally by \@ngrx/store or by library authors
246 * @type {?}
247 */
248const META_REDUCERS = new InjectionToken('@ngrx/store Meta Reducers');
249/**
250 * Concats the user provided meta reducers and the meta reducers provided on the multi
251 * injection token
252 * @type {?}
253 */
254const _RESOLVED_META_REDUCERS = new InjectionToken('@ngrx/store Internal Resolved Meta Reducers');
255/**
256 * Runtime checks defined by the user via an InjectionToken
257 * Defaults to `_USER_RUNTIME_CHECKS`
258 * @type {?}
259 */
260const USER_RUNTIME_CHECKS = new InjectionToken('@ngrx/store User Runtime Checks Config');
261/**
262 * Runtime checks defined by the user via forRoot()
263 * @type {?}
264 */
265const _USER_RUNTIME_CHECKS = new InjectionToken('@ngrx/store Internal User Runtime Checks Config');
266/**
267 * Runtime checks currently in use
268 * @type {?}
269 */
270const _ACTIVE_RUNTIME_CHECKS = new InjectionToken('@ngrx/store Internal Runtime Checks');
271/** @type {?} */
272const _ACTION_TYPE_UNIQUENESS_CHECK = new InjectionToken('@ngrx/store Check if Action types are unique');
273
274/**
275 * @fileoverview added by tsickle
276 * Generated from: src/utils.ts
277 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
278 */
279/**
280 * \@description
281 * Combines reducers for individual features into a single reducer.
282 *
283 * You can use this function to delegate handling of state transitions to multiple reducers, each acting on their
284 * own sub-state within the root state.
285 *
286 * \@usageNotes
287 *
288 * **Example combining two feature reducers into one "root" reducer**
289 *
290 * ```ts
291 * export const reducer = combineReducers({
292 * featureA: featureAReducer,
293 * featureB: featureBReducer
294 * });
295 * ```
296 *
297 * You can also override the initial states of the sub-features:
298 * ```ts
299 * export const reducer = combineReducers({
300 * featureA: featureAReducer,
301 * featureB: featureBReducer
302 * }, {
303 * featureA: { counterA: 13 },
304 * featureB: { counterB: 37 }
305 * });
306 * ```
307 * @param {?} reducers An object mapping keys of the root state to their corresponding feature reducer.
308 * @param {?=} initialState Provides a state value if the current state is `undefined`, as it is initially.
309 * @return {?} A reducer function.
310 *
311 */
312function combineReducers(reducers, initialState = {}) {
313 /** @type {?} */
314 const reducerKeys = Object.keys(reducers);
315 /** @type {?} */
316 const finalReducers = {};
317 for (let i = 0; i < reducerKeys.length; i++) {
318 /** @type {?} */
319 const key = reducerKeys[i];
320 if (typeof reducers[key] === 'function') {
321 finalReducers[key] = reducers[key];
322 }
323 }
324 /** @type {?} */
325 const finalReducerKeys = Object.keys(finalReducers);
326 return (/**
327 * @param {?} state
328 * @param {?} action
329 * @return {?}
330 */
331 function combination(state, action) {
332 state = state === undefined ? initialState : state;
333 /** @type {?} */
334 let hasChanged = false;
335 /** @type {?} */
336 const nextState = {};
337 for (let i = 0; i < finalReducerKeys.length; i++) {
338 /** @type {?} */
339 const key = finalReducerKeys[i];
340 /** @type {?} */
341 const reducer = finalReducers[key];
342 /** @type {?} */
343 const previousStateForKey = state[key];
344 /** @type {?} */
345 const nextStateForKey = reducer(previousStateForKey, action);
346 nextState[key] = nextStateForKey;
347 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
348 }
349 return hasChanged ? nextState : state;
350 });
351}
352/**
353 * @template T
354 * @param {?} object
355 * @param {?} keyToRemove
356 * @return {?}
357 */
358function omit(object, keyToRemove) {
359 return Object.keys(object)
360 .filter((/**
361 * @param {?} key
362 * @return {?}
363 */
364 (key) => key !== keyToRemove))
365 .reduce((/**
366 * @param {?} result
367 * @param {?} key
368 * @return {?}
369 */
370 (result, key) => Object.assign(result, { [key]: object[key] })), {});
371}
372/**
373 * @param {...?} functions
374 * @return {?}
375 */
376function compose(...functions) {
377 return (/**
378 * @param {?} arg
379 * @return {?}
380 */
381 function (arg) {
382 if (functions.length === 0) {
383 return arg;
384 }
385 /** @type {?} */
386 const last = functions[functions.length - 1];
387 /** @type {?} */
388 const rest = functions.slice(0, -1);
389 return rest.reduceRight((/**
390 * @param {?} composed
391 * @param {?} fn
392 * @return {?}
393 */
394 (composed, fn) => fn(composed)), last(arg));
395 });
396}
397/**
398 * @template T, V
399 * @param {?} reducerFactory
400 * @param {?=} metaReducers
401 * @return {?}
402 */
403function createReducerFactory(reducerFactory, metaReducers) {
404 if (Array.isArray(metaReducers) && metaReducers.length > 0) {
405 ((/** @type {?} */ (reducerFactory))) = compose.apply(null, [
406 ...metaReducers,
407 reducerFactory,
408 ]);
409 }
410 return (/**
411 * @param {?} reducers
412 * @param {?=} initialState
413 * @return {?}
414 */
415 (reducers, initialState) => {
416 /** @type {?} */
417 const reducer = reducerFactory(reducers);
418 return (/**
419 * @param {?} state
420 * @param {?} action
421 * @return {?}
422 */
423 (state, action) => {
424 state = state === undefined ? ((/** @type {?} */ (initialState))) : state;
425 return reducer(state, action);
426 });
427 });
428}
429/**
430 * @template T, V
431 * @param {?=} metaReducers
432 * @return {?}
433 */
434function createFeatureReducerFactory(metaReducers) {
435 /** @type {?} */
436 const reducerFactory = Array.isArray(metaReducers) && metaReducers.length > 0
437 ? compose(...metaReducers)
438 : (/**
439 * @param {?} r
440 * @return {?}
441 */
442 (r) => r);
443 return (/**
444 * @param {?} reducer
445 * @param {?=} initialState
446 * @return {?}
447 */
448 (reducer, initialState) => {
449 reducer = reducerFactory(reducer);
450 return (/**
451 * @param {?} state
452 * @param {?} action
453 * @return {?}
454 */
455 (state, action) => {
456 state = state === undefined ? initialState : state;
457 return reducer(state, action);
458 });
459 });
460}
461
462/**
463 * @fileoverview added by tsickle
464 * Generated from: src/reducer_manager.ts
465 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
466 */
467/**
468 * @abstract
469 */
470class ReducerObservable extends Observable {
471}
472/**
473 * @abstract
474 */
475class ReducerManagerDispatcher extends ActionsSubject {
476}
477/** @type {?} */
478const UPDATE = (/** @type {?} */ ('@ngrx/store/update-reducers'));
479class ReducerManager extends BehaviorSubject {
480 /**
481 * @param {?} dispatcher
482 * @param {?} initialState
483 * @param {?} reducers
484 * @param {?} reducerFactory
485 */
486 constructor(dispatcher, initialState, reducers, reducerFactory) {
487 super(reducerFactory(reducers, initialState));
488 this.dispatcher = dispatcher;
489 this.initialState = initialState;
490 this.reducers = reducers;
491 this.reducerFactory = reducerFactory;
492 }
493 /**
494 * @param {?} feature
495 * @return {?}
496 */
497 addFeature(feature) {
498 this.addFeatures([feature]);
499 }
500 /**
501 * @param {?} features
502 * @return {?}
503 */
504 addFeatures(features) {
505 /** @type {?} */
506 const reducers = features.reduce((/**
507 * @param {?} reducerDict
508 * @param {?} __1
509 * @return {?}
510 */
511 (reducerDict, { reducers, reducerFactory, metaReducers, initialState, key }) => {
512 /** @type {?} */
513 const reducer = typeof reducers === 'function'
514 ? createFeatureReducerFactory(metaReducers)(reducers, initialState)
515 : createReducerFactory(reducerFactory, metaReducers)(reducers, initialState);
516 reducerDict[key] = reducer;
517 return reducerDict;
518 }), (/** @type {?} */ ({})));
519 this.addReducers(reducers);
520 }
521 /**
522 * @param {?} feature
523 * @return {?}
524 */
525 removeFeature(feature) {
526 this.removeFeatures([feature]);
527 }
528 /**
529 * @param {?} features
530 * @return {?}
531 */
532 removeFeatures(features) {
533 this.removeReducers(features.map((/**
534 * @param {?} p
535 * @return {?}
536 */
537 (p) => p.key)));
538 }
539 /**
540 * @param {?} key
541 * @param {?} reducer
542 * @return {?}
543 */
544 addReducer(key, reducer) {
545 this.addReducers({ [key]: reducer });
546 }
547 /**
548 * @param {?} reducers
549 * @return {?}
550 */
551 addReducers(reducers) {
552 this.reducers = Object.assign(Object.assign({}, this.reducers), reducers);
553 this.updateReducers(Object.keys(reducers));
554 }
555 /**
556 * @param {?} featureKey
557 * @return {?}
558 */
559 removeReducer(featureKey) {
560 this.removeReducers([featureKey]);
561 }
562 /**
563 * @param {?} featureKeys
564 * @return {?}
565 */
566 removeReducers(featureKeys) {
567 featureKeys.forEach((/**
568 * @param {?} key
569 * @return {?}
570 */
571 (key) => {
572 this.reducers = (/** @type {?} */ (omit(this.reducers, key) /*TODO(#823)*/));
573 }));
574 this.updateReducers(featureKeys);
575 }
576 /**
577 * @private
578 * @param {?} featureKeys
579 * @return {?}
580 */
581 updateReducers(featureKeys) {
582 this.next(this.reducerFactory(this.reducers, this.initialState));
583 this.dispatcher.next((/** @type {?} */ ({
584 type: UPDATE,
585 features: featureKeys,
586 })));
587 }
588 /**
589 * @return {?}
590 */
591 ngOnDestroy() {
592 this.complete();
593 }
594}
595ReducerManager.decorators = [
596 { type: Injectable }
597];
598/** @nocollapse */
599ReducerManager.ctorParameters = () => [
600 { type: ReducerManagerDispatcher },
601 { type: undefined, decorators: [{ type: Inject, args: [INITIAL_STATE,] }] },
602 { type: undefined, decorators: [{ type: Inject, args: [INITIAL_REDUCERS,] }] },
603 { type: undefined, decorators: [{ type: Inject, args: [REDUCER_FACTORY,] }] }
604];
605if (false) {
606 /**
607 * @type {?}
608 * @private
609 */
610 ReducerManager.prototype.dispatcher;
611 /**
612 * @type {?}
613 * @private
614 */
615 ReducerManager.prototype.initialState;
616 /**
617 * @type {?}
618 * @private
619 */
620 ReducerManager.prototype.reducers;
621 /**
622 * @type {?}
623 * @private
624 */
625 ReducerManager.prototype.reducerFactory;
626}
627/** @type {?} */
628const REDUCER_MANAGER_PROVIDERS = [
629 ReducerManager,
630 { provide: ReducerObservable, useExisting: ReducerManager },
631 { provide: ReducerManagerDispatcher, useExisting: ActionsSubject },
632];
633
634/**
635 * @fileoverview added by tsickle
636 * Generated from: src/scanned_actions_subject.ts
637 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
638 */
639class ScannedActionsSubject extends Subject {
640 /**
641 * @return {?}
642 */
643 ngOnDestroy() {
644 this.complete();
645 }
646}
647ScannedActionsSubject.decorators = [
648 { type: Injectable }
649];
650/** @type {?} */
651const SCANNED_ACTIONS_SUBJECT_PROVIDERS = [
652 ScannedActionsSubject,
653];
654
655/**
656 * @fileoverview added by tsickle
657 * Generated from: src/state.ts
658 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
659 */
660/**
661 * @abstract
662 */
663class StateObservable extends Observable {
664}
665/**
666 * @template T
667 */
668class State extends BehaviorSubject {
669 /**
670 * @param {?} actions$
671 * @param {?} reducer$
672 * @param {?} scannedActions
673 * @param {?} initialState
674 */
675 constructor(actions$, reducer$, scannedActions, initialState) {
676 super(initialState);
677 /** @type {?} */
678 const actionsOnQueue$ = actions$.pipe(observeOn(queueScheduler));
679 /** @type {?} */
680 const withLatestReducer$ = actionsOnQueue$.pipe(withLatestFrom(reducer$));
681 /** @type {?} */
682 const seed = { state: initialState };
683 /** @type {?} */
684 const stateAndAction$ = withLatestReducer$.pipe(scan(reduceState, seed));
685 this.stateSubscription = stateAndAction$.subscribe((/**
686 * @param {?} __0
687 * @return {?}
688 */
689 ({ state, action }) => {
690 this.next(state);
691 scannedActions.next((/** @type {?} */ (action)));
692 }));
693 }
694 /**
695 * @return {?}
696 */
697 ngOnDestroy() {
698 this.stateSubscription.unsubscribe();
699 this.complete();
700 }
701}
702State.INIT = INIT;
703State.decorators = [
704 { type: Injectable }
705];
706/** @nocollapse */
707State.ctorParameters = () => [
708 { type: ActionsSubject },
709 { type: ReducerObservable },
710 { type: ScannedActionsSubject },
711 { type: undefined, decorators: [{ type: Inject, args: [INITIAL_STATE,] }] }
712];
713if (false) {
714 /** @type {?} */
715 State.INIT;
716 /**
717 * @type {?}
718 * @private
719 */
720 State.prototype.stateSubscription;
721}
722/**
723 * @template T, V
724 * @param {?=} stateActionPair
725 * @param {?=} __1
726 * @return {?}
727 */
728function reduceState(stateActionPair = { state: undefined }, [action, reducer]) {
729 const { state } = stateActionPair;
730 return { state: reducer(state, action), action };
731}
732/** @type {?} */
733const STATE_PROVIDERS = [
734 State,
735 { provide: StateObservable, useExisting: State },
736];
737
738/**
739 * @fileoverview added by tsickle
740 * Generated from: src/store.ts
741 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
742 */
743/**
744 * @template T
745 */
746class Store extends Observable {
747 /**
748 * @param {?} state$
749 * @param {?} actionsObserver
750 * @param {?} reducerManager
751 */
752 constructor(state$, actionsObserver, reducerManager) {
753 super();
754 this.actionsObserver = actionsObserver;
755 this.reducerManager = reducerManager;
756 this.source = state$;
757 }
758 /**
759 * @template Props, K
760 * @param {?} pathOrMapFn
761 * @param {...?} paths
762 * @return {?}
763 */
764 select(pathOrMapFn, ...paths) {
765 return ((/** @type {?} */ (select))).call(null, pathOrMapFn, ...paths)(this);
766 }
767 /**
768 * @template R
769 * @param {?} operator
770 * @return {?}
771 */
772 lift(operator) {
773 /** @type {?} */
774 const store = new Store(this, this.actionsObserver, this.reducerManager);
775 store.operator = operator;
776 return store;
777 }
778 /**
779 * @template V
780 * @param {?} action
781 * @return {?}
782 */
783 dispatch(action) {
784 this.actionsObserver.next(action);
785 }
786 /**
787 * @param {?} action
788 * @return {?}
789 */
790 next(action) {
791 this.actionsObserver.next(action);
792 }
793 /**
794 * @param {?} err
795 * @return {?}
796 */
797 error(err) {
798 this.actionsObserver.error(err);
799 }
800 /**
801 * @return {?}
802 */
803 complete() {
804 this.actionsObserver.complete();
805 }
806 /**
807 * @template State, Actions
808 * @param {?} key
809 * @param {?} reducer
810 * @return {?}
811 */
812 addReducer(key, reducer) {
813 this.reducerManager.addReducer(key, reducer);
814 }
815 /**
816 * @template Key
817 * @param {?} key
818 * @return {?}
819 */
820 removeReducer(key) {
821 this.reducerManager.removeReducer(key);
822 }
823}
824Store.decorators = [
825 { type: Injectable }
826];
827/** @nocollapse */
828Store.ctorParameters = () => [
829 { type: StateObservable },
830 { type: ActionsSubject },
831 { type: ReducerManager }
832];
833if (false) {
834 /**
835 * @type {?}
836 * @private
837 */
838 Store.prototype.actionsObserver;
839 /**
840 * @type {?}
841 * @private
842 */
843 Store.prototype.reducerManager;
844}
845/** @type {?} */
846const STORE_PROVIDERS = [Store];
847/**
848 * @template T, Props, K
849 * @param {?} pathOrMapFn
850 * @param {?=} propsOrPath
851 * @param {...?} paths
852 * @return {?}
853 */
854function select(pathOrMapFn, propsOrPath, ...paths) {
855 return (/**
856 * @param {?} source$
857 * @return {?}
858 */
859 function selectOperator(source$) {
860 /** @type {?} */
861 let mapped$;
862 if (typeof pathOrMapFn === 'string') {
863 /** @type {?} */
864 const pathSlices = [(/** @type {?} */ (propsOrPath)), ...paths].filter(Boolean);
865 mapped$ = source$.pipe(pluck(pathOrMapFn, ...pathSlices));
866 }
867 else if (typeof pathOrMapFn === 'function') {
868 mapped$ = source$.pipe(map((/**
869 * @param {?} source
870 * @return {?}
871 */
872 (source) => pathOrMapFn(source, (/** @type {?} */ (propsOrPath))))));
873 }
874 else {
875 throw new TypeError(`Unexpected type '${typeof pathOrMapFn}' in select operator,` +
876 ` expected 'string' or 'function'`);
877 }
878 return mapped$.pipe(distinctUntilChanged());
879 });
880}
881
882/**
883 * @fileoverview added by tsickle
884 * Generated from: src/flags.ts
885 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
886 */
887/** @type {?} */
888let _ngrxMockEnvironment = false;
889/**
890 * @param {?} value
891 * @return {?}
892 */
893function setNgrxMockEnvironment(value) {
894 _ngrxMockEnvironment = value;
895}
896/**
897 * @return {?}
898 */
899function isNgrxMockEnvironment() {
900 return _ngrxMockEnvironment;
901}
902
903/**
904 * @fileoverview added by tsickle
905 * Generated from: src/selector.ts
906 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
907 */
908/**
909 * @record
910 * @template State, Result, ProjectorFn
911 */
912function MemoizedSelector() { }
913if (false) {
914 /** @type {?} */
915 MemoizedSelector.prototype.projector;
916 /** @type {?} */
917 MemoizedSelector.prototype.setResult;
918 /** @type {?} */
919 MemoizedSelector.prototype.clearResult;
920 /**
921 * @return {?}
922 */
923 MemoizedSelector.prototype.release = function () { };
924}
925/**
926 * @record
927 * @template State, Props, Result, ProjectorFn
928 */
929function MemoizedSelectorWithProps() { }
930if (false) {
931 /** @type {?} */
932 MemoizedSelectorWithProps.prototype.projector;
933 /** @type {?} */
934 MemoizedSelectorWithProps.prototype.setResult;
935 /** @type {?} */
936 MemoizedSelectorWithProps.prototype.clearResult;
937 /**
938 * @return {?}
939 */
940 MemoizedSelectorWithProps.prototype.release = function () { };
941}
942/**
943 * @param {?} a
944 * @param {?} b
945 * @return {?}
946 */
947function isEqualCheck(a, b) {
948 return a === b;
949}
950/**
951 * @param {?} args
952 * @param {?} lastArguments
953 * @param {?} comparator
954 * @return {?}
955 */
956function isArgumentsChanged(args, lastArguments, comparator) {
957 for (let i = 0; i < args.length; i++) {
958 if (!comparator(args[i], lastArguments[i])) {
959 return true;
960 }
961 }
962 return false;
963}
964/**
965 * @param {?} projectionFn
966 * @param {?} isResultEqual
967 * @return {?}
968 */
969function resultMemoize(projectionFn, isResultEqual) {
970 return defaultMemoize(projectionFn, isEqualCheck, isResultEqual);
971}
972/**
973 * @param {?} projectionFn
974 * @param {?=} isArgumentsEqual
975 * @param {?=} isResultEqual
976 * @return {?}
977 */
978function defaultMemoize(projectionFn, isArgumentsEqual = isEqualCheck, isResultEqual = isEqualCheck) {
979 /** @type {?} */
980 let lastArguments = null;
981 // tslint:disable-next-line:no-any anything could be the result.
982 /** @type {?} */
983 let lastResult = null;
984 /** @type {?} */
985 let overrideResult;
986 /**
987 * @return {?}
988 */
989 function reset() {
990 lastArguments = null;
991 lastResult = null;
992 }
993 /**
994 * @param {?=} result
995 * @return {?}
996 */
997 function setResult(result = undefined) {
998 overrideResult = { result };
999 }
1000 /**
1001 * @return {?}
1002 */
1003 function clearResult() {
1004 overrideResult = undefined;
1005 }
1006 // tslint:disable-next-line:no-any anything could be the result.
1007 /**
1008 * @return {?}
1009 */
1010 function memoized() {
1011 if (overrideResult !== undefined) {
1012 return overrideResult.result;
1013 }
1014 if (!lastArguments) {
1015 lastResult = projectionFn.apply(null, (/** @type {?} */ (arguments)));
1016 lastArguments = arguments;
1017 return lastResult;
1018 }
1019 if (!isArgumentsChanged(arguments, lastArguments, isArgumentsEqual)) {
1020 return lastResult;
1021 }
1022 /** @type {?} */
1023 const newResult = projectionFn.apply(null, (/** @type {?} */ (arguments)));
1024 lastArguments = arguments;
1025 if (isResultEqual(lastResult, newResult)) {
1026 return lastResult;
1027 }
1028 lastResult = newResult;
1029 return newResult;
1030 }
1031 return { memoized, reset, setResult, clearResult };
1032}
1033/**
1034 * @param {...?} input
1035 * @return {?}
1036 */
1037function createSelector(...input) {
1038 return createSelectorFactory(defaultMemoize)(...input);
1039}
1040/**
1041 * @param {?} state
1042 * @param {?} selectors
1043 * @param {?} props
1044 * @param {?} memoizedProjector
1045 * @return {?}
1046 */
1047function defaultStateFn(state, selectors, props, memoizedProjector) {
1048 if (props === undefined) {
1049 /** @type {?} */
1050 const args = ((/** @type {?} */ (selectors))).map((/**
1051 * @param {?} fn
1052 * @return {?}
1053 */
1054 (fn) => fn(state)));
1055 return memoizedProjector.memoized.apply(null, args);
1056 }
1057 /** @type {?} */
1058 const args = ((/** @type {?} */ (selectors))).map((/**
1059 * @param {?} fn
1060 * @return {?}
1061 */
1062 (fn) => fn(state, props)));
1063 return memoizedProjector.memoized.apply(null, [...args, props]);
1064}
1065/**
1066 *
1067 * \@usageNotes
1068 *
1069 * **Creating a Selector Factory Where Array Order Does Not Matter**
1070 *
1071 * ```ts
1072 * function removeMatch(arr: string[], target: string): string[] {
1073 * const matchIndex = arr.indexOf(target);
1074 * return [...arr.slice(0, matchIndex), ...arr.slice(matchIndex + 1)];
1075 * }
1076 *
1077 * function orderDoesNotMatterComparer(a: any, b: any): boolean {
1078 * if (!Array.isArray(a) || !Array.isArray(b)) {
1079 * return a === b;
1080 * }
1081 * if (a.length !== b.length) {
1082 * return false;
1083 * }
1084 * let tempB = [...b];
1085 * function reduceToDetermineIfArraysContainSameContents(
1086 * previousCallResult: boolean,
1087 * arrayMember: any
1088 * ): boolean {
1089 * if (previousCallResult === false) {
1090 * return false;
1091 * }
1092 * if (tempB.includes(arrayMember)) {
1093 * tempB = removeMatch(tempB, arrayMember);
1094 * return true;
1095 * }
1096 * return false;
1097 * }
1098 * return a.reduce(reduceToDetermineIfArraysContainSameContents, true);
1099 * }
1100 *
1101 * export const creactOrderDoesNotMatterSelector = createSelectorFactory(
1102 * (projectionFun) => defaultMemoize(
1103 * projectionFun,
1104 * orderDoesNotMatterComparer,
1105 * orderDoesNotMatterComparer
1106 * )
1107 * );
1108 * ```
1109 *
1110 * **Creating an Alternative Memoization Strategy**
1111 *
1112 * ```ts
1113 * function serialize(x: any): string {
1114 * return JSON.stringify(x);
1115 * }
1116 *
1117 * export const createFullHistorySelector = createSelectorFactory(
1118 * (projectionFunction) => {
1119 * const cache = {};
1120 *
1121 * function memoized() {
1122 * const serializedArguments = serialize(...arguments);
1123 * if (cache[serializedArguments] != null) {
1124 * cache[serializedArguments] = projectionFunction.apply(null, arguments);
1125 * }
1126 * return cache[serializedArguments];
1127 * }
1128 * return {
1129 * memoized,
1130 * reset: () => {},
1131 * setResult: () => {},
1132 * clearResult: () => {},
1133 * };
1134 * }
1135 * );
1136 * ```
1137 *
1138 *
1139 * @param {?} memoize The function used to memoize selectors
1140 * @param {?=} options Config Object that may include a `stateFn` function defining how to return the selector's value, given the entire `Store`'s state, parent `Selector`s, `Props`, and a `MemoizedProjection`
1141 *
1142 * @return {?}
1143 */
1144function createSelectorFactory(memoize, options = {
1145 stateFn: defaultStateFn,
1146}) {
1147 return (/**
1148 * @param {...?} input
1149 * @return {?}
1150 */
1151 function (...input) {
1152 /** @type {?} */
1153 let args = input;
1154 if (Array.isArray(args[0])) {
1155 const [head, ...tail] = args;
1156 args = [...head, ...tail];
1157 }
1158 /** @type {?} */
1159 const selectors = args.slice(0, args.length - 1);
1160 /** @type {?} */
1161 const projector = args[args.length - 1];
1162 /** @type {?} */
1163 const memoizedSelectors = selectors.filter((/**
1164 * @param {?} selector
1165 * @return {?}
1166 */
1167 (selector) => selector.release && typeof selector.release === 'function'));
1168 /** @type {?} */
1169 const memoizedProjector = memoize((/**
1170 * @param {...?} selectors
1171 * @return {?}
1172 */
1173 function (...selectors) {
1174 return projector.apply(null, selectors);
1175 }));
1176 /** @type {?} */
1177 const memoizedState = defaultMemoize((/**
1178 * @param {?} state
1179 * @param {?} props
1180 * @return {?}
1181 */
1182 function (state, props) {
1183 return options.stateFn.apply(null, [
1184 state,
1185 selectors,
1186 props,
1187 memoizedProjector,
1188 ]);
1189 }));
1190 /**
1191 * @return {?}
1192 */
1193 function release() {
1194 memoizedState.reset();
1195 memoizedProjector.reset();
1196 memoizedSelectors.forEach((/**
1197 * @param {?} selector
1198 * @return {?}
1199 */
1200 (selector) => selector.release()));
1201 }
1202 return Object.assign(memoizedState.memoized, {
1203 release,
1204 projector: memoizedProjector.memoized,
1205 setResult: memoizedState.setResult,
1206 clearResult: memoizedState.clearResult,
1207 });
1208 });
1209}
1210/**
1211 * @param {?} featureName
1212 * @return {?}
1213 */
1214function createFeatureSelector(featureName) {
1215 return createSelector((/**
1216 * @param {?} state
1217 * @return {?}
1218 */
1219 (state) => {
1220 /** @type {?} */
1221 const featureState = state[featureName];
1222 if (!isNgrxMockEnvironment() && isDevMode() && !(featureName in state)) {
1223 console.warn(`@ngrx/store: The feature name \"${featureName}\" does ` +
1224 'not exist in the state, therefore createFeatureSelector ' +
1225 'cannot access it. Be sure it is imported in a loaded module ' +
1226 `using StoreModule.forRoot('${featureName}', ...) or ` +
1227 `StoreModule.forFeature('${featureName}', ...). If the default ` +
1228 'state is intended to be undefined, as is the case with router ' +
1229 'state, this development-only warning message can be ignored.');
1230 }
1231 return featureState;
1232 }), (/**
1233 * @param {?} featureState
1234 * @return {?}
1235 */
1236 (featureState) => featureState));
1237}
1238
1239/**
1240 * @fileoverview added by tsickle
1241 * Generated from: src/meta-reducers/utils.ts
1242 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1243 */
1244/** @type {?} */
1245const RUNTIME_CHECK_URL = 'https://ngrx.io/guide/store/configuration/runtime-checks';
1246/**
1247 * @param {?} target
1248 * @return {?}
1249 */
1250function isUndefined(target) {
1251 return target === undefined;
1252}
1253/**
1254 * @param {?} target
1255 * @return {?}
1256 */
1257function isNull(target) {
1258 return target === null;
1259}
1260/**
1261 * @param {?} target
1262 * @return {?}
1263 */
1264function isArray(target) {
1265 return Array.isArray(target);
1266}
1267/**
1268 * @param {?} target
1269 * @return {?}
1270 */
1271function isString(target) {
1272 return typeof target === 'string';
1273}
1274/**
1275 * @param {?} target
1276 * @return {?}
1277 */
1278function isBoolean(target) {
1279 return typeof target === 'boolean';
1280}
1281/**
1282 * @param {?} target
1283 * @return {?}
1284 */
1285function isNumber(target) {
1286 return typeof target === 'number';
1287}
1288/**
1289 * @param {?} target
1290 * @return {?}
1291 */
1292function isObjectLike(target) {
1293 return typeof target === 'object' && target !== null;
1294}
1295/**
1296 * @param {?} target
1297 * @return {?}
1298 */
1299function isObject(target) {
1300 return isObjectLike(target) && !isArray(target);
1301}
1302/**
1303 * @param {?} target
1304 * @return {?}
1305 */
1306function isPlainObject(target) {
1307 if (!isObject(target)) {
1308 return false;
1309 }
1310 /** @type {?} */
1311 const targetPrototype = Object.getPrototypeOf(target);
1312 return targetPrototype === Object.prototype || targetPrototype === null;
1313}
1314/**
1315 * @param {?} target
1316 * @return {?}
1317 */
1318function isFunction(target) {
1319 return typeof target === 'function';
1320}
1321/**
1322 * @param {?} target
1323 * @return {?}
1324 */
1325function isComponent(target) {
1326 return isFunction(target) && target.hasOwnProperty('ɵcmp');
1327}
1328/**
1329 * @param {?} target
1330 * @param {?} propertyName
1331 * @return {?}
1332 */
1333function hasOwnProperty(target, propertyName) {
1334 return Object.prototype.hasOwnProperty.call(target, propertyName);
1335}
1336
1337/**
1338 * @fileoverview added by tsickle
1339 * Generated from: src/meta-reducers/immutability_reducer.ts
1340 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1341 */
1342/**
1343 * @param {?} reducer
1344 * @param {?} checks
1345 * @return {?}
1346 */
1347function immutabilityCheckMetaReducer(reducer, checks) {
1348 return (/**
1349 * @param {?} state
1350 * @param {?} action
1351 * @return {?}
1352 */
1353 function (state, action) {
1354 /** @type {?} */
1355 const act = checks.action(action) ? freeze(action) : action;
1356 /** @type {?} */
1357 const nextState = reducer(state, act);
1358 return checks.state() ? freeze(nextState) : nextState;
1359 });
1360}
1361/**
1362 * @param {?} target
1363 * @return {?}
1364 */
1365function freeze(target) {
1366 Object.freeze(target);
1367 /** @type {?} */
1368 const targetIsFunction = isFunction(target);
1369 Object.getOwnPropertyNames(target).forEach((/**
1370 * @param {?} prop
1371 * @return {?}
1372 */
1373 (prop) => {
1374 // Ignore Ivy properties, ref: https://github.com/ngrx/platform/issues/2109#issuecomment-582689060
1375 if (prop.startsWith('ɵ')) {
1376 return;
1377 }
1378 if (hasOwnProperty(target, prop) &&
1379 (targetIsFunction
1380 ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments'
1381 : true)) {
1382 /** @type {?} */
1383 const propValue = target[prop];
1384 if ((isObjectLike(propValue) || isFunction(propValue)) &&
1385 !Object.isFrozen(propValue)) {
1386 freeze(propValue);
1387 }
1388 }
1389 }));
1390 return target;
1391}
1392
1393/**
1394 * @fileoverview added by tsickle
1395 * Generated from: src/meta-reducers/serialization_reducer.ts
1396 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1397 */
1398/**
1399 * @param {?} reducer
1400 * @param {?} checks
1401 * @return {?}
1402 */
1403function serializationCheckMetaReducer(reducer, checks) {
1404 return (/**
1405 * @param {?} state
1406 * @param {?} action
1407 * @return {?}
1408 */
1409 function (state, action) {
1410 if (checks.action(action)) {
1411 /** @type {?} */
1412 const unserializableAction = getUnserializable(action);
1413 throwIfUnserializable(unserializableAction, 'action');
1414 }
1415 /** @type {?} */
1416 const nextState = reducer(state, action);
1417 if (checks.state()) {
1418 /** @type {?} */
1419 const unserializableState = getUnserializable(nextState);
1420 throwIfUnserializable(unserializableState, 'state');
1421 }
1422 return nextState;
1423 });
1424}
1425/**
1426 * @param {?=} target
1427 * @param {?=} path
1428 * @return {?}
1429 */
1430function getUnserializable(target, path = []) {
1431 // Guard against undefined and null, e.g. a reducer that returns undefined
1432 if ((isUndefined(target) || isNull(target)) && path.length === 0) {
1433 return {
1434 path: ['root'],
1435 value: target,
1436 };
1437 }
1438 /** @type {?} */
1439 const keys = Object.keys(target);
1440 return keys.reduce((/**
1441 * @param {?} result
1442 * @param {?} key
1443 * @return {?}
1444 */
1445 (result, key) => {
1446 if (result) {
1447 return result;
1448 }
1449 /** @type {?} */
1450 const value = ((/** @type {?} */ (target)))[key];
1451 // Ignore Ivy components
1452 if (isComponent(value)) {
1453 return result;
1454 }
1455 if (isUndefined(value) ||
1456 isNull(value) ||
1457 isNumber(value) ||
1458 isBoolean(value) ||
1459 isString(value) ||
1460 isArray(value)) {
1461 return false;
1462 }
1463 if (isPlainObject(value)) {
1464 return getUnserializable(value, [...path, key]);
1465 }
1466 return {
1467 path: [...path, key],
1468 value,
1469 };
1470 }), false);
1471}
1472/**
1473 * @param {?} unserializable
1474 * @param {?} context
1475 * @return {?}
1476 */
1477function throwIfUnserializable(unserializable, context) {
1478 if (unserializable === false) {
1479 return;
1480 }
1481 /** @type {?} */
1482 const unserializablePath = unserializable.path.join('.');
1483 /** @type {?} */
1484 const error = new Error(`Detected unserializable ${context} at "${unserializablePath}". ${RUNTIME_CHECK_URL}#strict${context}serializability`);
1485 error.value = unserializable.value;
1486 error.unserializablePath = unserializablePath;
1487 throw error;
1488}
1489
1490/**
1491 * @fileoverview added by tsickle
1492 * Generated from: src/meta-reducers/inNgZoneAssert_reducer.ts
1493 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1494 */
1495/**
1496 * @param {?} reducer
1497 * @param {?} checks
1498 * @return {?}
1499 */
1500function inNgZoneAssertMetaReducer(reducer, checks) {
1501 return (/**
1502 * @param {?} state
1503 * @param {?} action
1504 * @return {?}
1505 */
1506 function (state, action) {
1507 if (checks.action(action) && !NgZone.isInAngularZone()) {
1508 throw new Error(`Action '${action.type}' running outside NgZone. ${RUNTIME_CHECK_URL}#strictactionwithinngzone`);
1509 }
1510 return reducer(state, action);
1511 });
1512}
1513
1514/**
1515 * @fileoverview added by tsickle
1516 * Generated from: src/meta-reducers/index.ts
1517 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1518 */
1519
1520/**
1521 * @fileoverview added by tsickle
1522 * Generated from: src/runtime_checks.ts
1523 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1524 */
1525/**
1526 * @param {?=} runtimeChecks
1527 * @return {?}
1528 */
1529function createActiveRuntimeChecks(runtimeChecks) {
1530 if (isDevMode()) {
1531 return Object.assign({ strictStateSerializability: false, strictActionSerializability: false, strictStateImmutability: true, strictActionImmutability: true, strictActionWithinNgZone: false, strictActionTypeUniqueness: false }, runtimeChecks);
1532 }
1533 return {
1534 strictStateSerializability: false,
1535 strictActionSerializability: false,
1536 strictStateImmutability: false,
1537 strictActionImmutability: false,
1538 strictActionWithinNgZone: false,
1539 strictActionTypeUniqueness: false,
1540 };
1541}
1542/**
1543 * @param {?} __0
1544 * @return {?}
1545 */
1546function createSerializationCheckMetaReducer({ strictActionSerializability, strictStateSerializability, }) {
1547 return (/**
1548 * @param {?} reducer
1549 * @return {?}
1550 */
1551 (reducer) => strictActionSerializability || strictStateSerializability
1552 ? serializationCheckMetaReducer(reducer, {
1553 action: (/**
1554 * @param {?} action
1555 * @return {?}
1556 */
1557 (action) => strictActionSerializability && !ignoreNgrxAction(action)),
1558 state: (/**
1559 * @return {?}
1560 */
1561 () => strictStateSerializability),
1562 })
1563 : reducer);
1564}
1565/**
1566 * @param {?} __0
1567 * @return {?}
1568 */
1569function createImmutabilityCheckMetaReducer({ strictActionImmutability, strictStateImmutability, }) {
1570 return (/**
1571 * @param {?} reducer
1572 * @return {?}
1573 */
1574 (reducer) => strictActionImmutability || strictStateImmutability
1575 ? immutabilityCheckMetaReducer(reducer, {
1576 action: (/**
1577 * @param {?} action
1578 * @return {?}
1579 */
1580 (action) => strictActionImmutability && !ignoreNgrxAction(action)),
1581 state: (/**
1582 * @return {?}
1583 */
1584 () => strictStateImmutability),
1585 })
1586 : reducer);
1587}
1588/**
1589 * @param {?} action
1590 * @return {?}
1591 */
1592function ignoreNgrxAction(action) {
1593 return action.type.startsWith('@ngrx');
1594}
1595/**
1596 * @param {?} __0
1597 * @return {?}
1598 */
1599function createInNgZoneCheckMetaReducer({ strictActionWithinNgZone, }) {
1600 return (/**
1601 * @param {?} reducer
1602 * @return {?}
1603 */
1604 (reducer) => strictActionWithinNgZone
1605 ? inNgZoneAssertMetaReducer(reducer, {
1606 action: (/**
1607 * @param {?} action
1608 * @return {?}
1609 */
1610 (action) => strictActionWithinNgZone && !ignoreNgrxAction(action)),
1611 })
1612 : reducer);
1613}
1614/**
1615 * @param {?=} runtimeChecks
1616 * @return {?}
1617 */
1618function provideRuntimeChecks(runtimeChecks) {
1619 return [
1620 {
1621 provide: _USER_RUNTIME_CHECKS,
1622 useValue: runtimeChecks,
1623 },
1624 {
1625 provide: USER_RUNTIME_CHECKS,
1626 useFactory: _runtimeChecksFactory,
1627 deps: [_USER_RUNTIME_CHECKS],
1628 },
1629 {
1630 provide: _ACTIVE_RUNTIME_CHECKS,
1631 deps: [USER_RUNTIME_CHECKS],
1632 useFactory: createActiveRuntimeChecks,
1633 },
1634 {
1635 provide: META_REDUCERS,
1636 multi: true,
1637 deps: [_ACTIVE_RUNTIME_CHECKS],
1638 useFactory: createImmutabilityCheckMetaReducer,
1639 },
1640 {
1641 provide: META_REDUCERS,
1642 multi: true,
1643 deps: [_ACTIVE_RUNTIME_CHECKS],
1644 useFactory: createSerializationCheckMetaReducer,
1645 },
1646 {
1647 provide: META_REDUCERS,
1648 multi: true,
1649 deps: [_ACTIVE_RUNTIME_CHECKS],
1650 useFactory: createInNgZoneCheckMetaReducer,
1651 },
1652 ];
1653}
1654/**
1655 * @return {?}
1656 */
1657function checkForActionTypeUniqueness() {
1658 return [
1659 {
1660 provide: _ACTION_TYPE_UNIQUENESS_CHECK,
1661 multi: true,
1662 deps: [_ACTIVE_RUNTIME_CHECKS],
1663 useFactory: _actionTypeUniquenessCheck,
1664 },
1665 ];
1666}
1667/**
1668 * @param {?} runtimeChecks
1669 * @return {?}
1670 */
1671function _runtimeChecksFactory(runtimeChecks) {
1672 return runtimeChecks;
1673}
1674/**
1675 * @param {?} config
1676 * @return {?}
1677 */
1678function _actionTypeUniquenessCheck(config) {
1679 if (!config.strictActionTypeUniqueness) {
1680 return;
1681 }
1682 /** @type {?} */
1683 const duplicates = Object.entries(REGISTERED_ACTION_TYPES)
1684 .filter((/**
1685 * @param {?} __0
1686 * @return {?}
1687 */
1688 ([, registrations]) => registrations > 1))
1689 .map((/**
1690 * @param {?} __0
1691 * @return {?}
1692 */
1693 ([type]) => type));
1694 if (duplicates.length) {
1695 throw new Error(`Action types are registered more than once, ${duplicates
1696 .map((/**
1697 * @param {?} type
1698 * @return {?}
1699 */
1700 (type) => `"${type}"`))
1701 .join(', ')}. ${RUNTIME_CHECK_URL}#strictactiontypeuniqueness`);
1702 }
1703}
1704
1705/**
1706 * @fileoverview added by tsickle
1707 * Generated from: src/store_module.ts
1708 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1709 */
1710class StoreRootModule {
1711 /**
1712 * @param {?} actions$
1713 * @param {?} reducer$
1714 * @param {?} scannedActions$
1715 * @param {?} store
1716 * @param {?} guard
1717 * @param {?} actionCheck
1718 */
1719 constructor(actions$, reducer$, scannedActions$, store, guard, actionCheck) { }
1720}
1721StoreRootModule.decorators = [
1722 { type: NgModule, args: [{},] }
1723];
1724/** @nocollapse */
1725StoreRootModule.ctorParameters = () => [
1726 { type: ActionsSubject },
1727 { type: ReducerObservable },
1728 { type: ScannedActionsSubject },
1729 { type: Store },
1730 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [_ROOT_STORE_GUARD,] }] },
1731 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [_ACTION_TYPE_UNIQUENESS_CHECK,] }] }
1732];
1733class StoreFeatureModule {
1734 /**
1735 * @param {?} features
1736 * @param {?} featureReducers
1737 * @param {?} reducerManager
1738 * @param {?} root
1739 * @param {?} actionCheck
1740 */
1741 constructor(features, featureReducers, reducerManager, root, actionCheck) {
1742 this.features = features;
1743 this.featureReducers = featureReducers;
1744 this.reducerManager = reducerManager;
1745 /** @type {?} */
1746 const feats = features.map((/**
1747 * @param {?} feature
1748 * @param {?} index
1749 * @return {?}
1750 */
1751 (feature, index) => {
1752 /** @type {?} */
1753 const featureReducerCollection = featureReducers.shift();
1754 /** @type {?} */
1755 const reducers = (/** @type {?} */ (featureReducerCollection /*TODO(#823)*/))[index];
1756 return Object.assign(Object.assign({}, feature), { reducers, initialState: _initialStateFactory(feature.initialState) });
1757 }));
1758 reducerManager.addFeatures(feats);
1759 }
1760 /**
1761 * @return {?}
1762 */
1763 ngOnDestroy() {
1764 this.reducerManager.removeFeatures(this.features);
1765 }
1766}
1767StoreFeatureModule.decorators = [
1768 { type: NgModule, args: [{},] }
1769];
1770/** @nocollapse */
1771StoreFeatureModule.ctorParameters = () => [
1772 { type: Array, decorators: [{ type: Inject, args: [_STORE_FEATURES,] }] },
1773 { type: Array, decorators: [{ type: Inject, args: [FEATURE_REDUCERS,] }] },
1774 { type: ReducerManager },
1775 { type: StoreRootModule },
1776 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [_ACTION_TYPE_UNIQUENESS_CHECK,] }] }
1777];
1778if (false) {
1779 /**
1780 * @type {?}
1781 * @private
1782 */
1783 StoreFeatureModule.prototype.features;
1784 /**
1785 * @type {?}
1786 * @private
1787 */
1788 StoreFeatureModule.prototype.featureReducers;
1789 /**
1790 * @type {?}
1791 * @private
1792 */
1793 StoreFeatureModule.prototype.reducerManager;
1794}
1795/**
1796 * @record
1797 * @template T, V
1798 */
1799function StoreConfig() { }
1800if (false) {
1801 /** @type {?|undefined} */
1802 StoreConfig.prototype.initialState;
1803 /** @type {?|undefined} */
1804 StoreConfig.prototype.reducerFactory;
1805 /** @type {?|undefined} */
1806 StoreConfig.prototype.metaReducers;
1807}
1808/**
1809 * @record
1810 * @template T, V
1811 */
1812function RootStoreConfig() { }
1813if (false) {
1814 /** @type {?|undefined} */
1815 RootStoreConfig.prototype.runtimeChecks;
1816}
1817/**
1818 * An object with the name and the reducer for the feature.
1819 * @record
1820 * @template T, V
1821 */
1822function FeatureSlice() { }
1823if (false) {
1824 /** @type {?} */
1825 FeatureSlice.prototype.name;
1826 /** @type {?} */
1827 FeatureSlice.prototype.reducer;
1828}
1829class StoreModule {
1830 /**
1831 * @param {?} reducers
1832 * @param {?=} config
1833 * @return {?}
1834 */
1835 static forRoot(reducers, config = {}) {
1836 return {
1837 ngModule: StoreRootModule,
1838 providers: [
1839 {
1840 provide: _ROOT_STORE_GUARD,
1841 useFactory: _provideForRootGuard,
1842 deps: [[Store, new Optional(), new SkipSelf()]],
1843 },
1844 { provide: _INITIAL_STATE, useValue: config.initialState },
1845 {
1846 provide: INITIAL_STATE,
1847 useFactory: _initialStateFactory,
1848 deps: [_INITIAL_STATE],
1849 },
1850 { provide: _INITIAL_REDUCERS, useValue: reducers },
1851 {
1852 provide: _STORE_REDUCERS,
1853 useExisting: reducers instanceof InjectionToken ? reducers : _INITIAL_REDUCERS,
1854 },
1855 {
1856 provide: INITIAL_REDUCERS,
1857 deps: [Injector, _INITIAL_REDUCERS, [new Inject(_STORE_REDUCERS)]],
1858 useFactory: _createStoreReducers,
1859 },
1860 {
1861 provide: USER_PROVIDED_META_REDUCERS,
1862 useValue: config.metaReducers ? config.metaReducers : [],
1863 },
1864 {
1865 provide: _RESOLVED_META_REDUCERS,
1866 deps: [META_REDUCERS, USER_PROVIDED_META_REDUCERS],
1867 useFactory: _concatMetaReducers,
1868 },
1869 {
1870 provide: _REDUCER_FACTORY,
1871 useValue: config.reducerFactory
1872 ? config.reducerFactory
1873 : combineReducers,
1874 },
1875 {
1876 provide: REDUCER_FACTORY,
1877 deps: [_REDUCER_FACTORY, _RESOLVED_META_REDUCERS],
1878 useFactory: createReducerFactory,
1879 },
1880 ACTIONS_SUBJECT_PROVIDERS,
1881 REDUCER_MANAGER_PROVIDERS,
1882 SCANNED_ACTIONS_SUBJECT_PROVIDERS,
1883 STATE_PROVIDERS,
1884 STORE_PROVIDERS,
1885 provideRuntimeChecks(config.runtimeChecks),
1886 checkForActionTypeUniqueness(),
1887 ],
1888 };
1889 }
1890 /**
1891 * @param {?} featureNameOrSlice
1892 * @param {?=} reducersOrConfig
1893 * @param {?=} config
1894 * @return {?}
1895 */
1896 static forFeature(featureNameOrSlice, reducersOrConfig, config = {}) {
1897 return {
1898 ngModule: StoreFeatureModule,
1899 providers: [
1900 {
1901 provide: _FEATURE_CONFIGS,
1902 multi: true,
1903 useValue: typeof featureNameOrSlice === 'string' ? config : {},
1904 },
1905 {
1906 provide: STORE_FEATURES,
1907 multi: true,
1908 useValue: {
1909 key: typeof featureNameOrSlice === 'string'
1910 ? featureNameOrSlice
1911 : featureNameOrSlice.name,
1912 reducerFactory: !(config instanceof InjectionToken) && config.reducerFactory
1913 ? config.reducerFactory
1914 : combineReducers,
1915 metaReducers: !(config instanceof InjectionToken) && config.metaReducers
1916 ? config.metaReducers
1917 : [],
1918 initialState: !(config instanceof InjectionToken) && config.initialState
1919 ? config.initialState
1920 : undefined,
1921 },
1922 },
1923 {
1924 provide: _STORE_FEATURES,
1925 deps: [Injector, _FEATURE_CONFIGS, STORE_FEATURES],
1926 useFactory: _createFeatureStore,
1927 },
1928 {
1929 provide: _FEATURE_REDUCERS,
1930 multi: true,
1931 useValue: typeof featureNameOrSlice === 'string'
1932 ? reducersOrConfig
1933 : featureNameOrSlice.reducer,
1934 },
1935 {
1936 provide: _FEATURE_REDUCERS_TOKEN,
1937 multi: true,
1938 useExisting: reducersOrConfig instanceof InjectionToken
1939 ? reducersOrConfig
1940 : _FEATURE_REDUCERS,
1941 },
1942 {
1943 provide: FEATURE_REDUCERS,
1944 multi: true,
1945 deps: [
1946 Injector,
1947 _FEATURE_REDUCERS,
1948 [new Inject(_FEATURE_REDUCERS_TOKEN)],
1949 ],
1950 useFactory: _createFeatureReducers,
1951 },
1952 checkForActionTypeUniqueness(),
1953 ],
1954 };
1955 }
1956}
1957StoreModule.decorators = [
1958 { type: NgModule, args: [{},] }
1959];
1960/**
1961 * @param {?} injector
1962 * @param {?} reducers
1963 * @return {?}
1964 */
1965function _createStoreReducers(injector, reducers) {
1966 return reducers instanceof InjectionToken ? injector.get(reducers) : reducers;
1967}
1968/**
1969 * @param {?} injector
1970 * @param {?} configs
1971 * @param {?} featureStores
1972 * @return {?}
1973 */
1974function _createFeatureStore(injector, configs, featureStores) {
1975 return featureStores.map((/**
1976 * @param {?} feat
1977 * @param {?} index
1978 * @return {?}
1979 */
1980 (feat, index) => {
1981 if (configs[index] instanceof InjectionToken) {
1982 /** @type {?} */
1983 const conf = injector.get(configs[index]);
1984 return {
1985 key: feat.key,
1986 reducerFactory: conf.reducerFactory
1987 ? conf.reducerFactory
1988 : combineReducers,
1989 metaReducers: conf.metaReducers ? conf.metaReducers : [],
1990 initialState: conf.initialState,
1991 };
1992 }
1993 return feat;
1994 }));
1995}
1996/**
1997 * @param {?} injector
1998 * @param {?} reducerCollection
1999 * @return {?}
2000 */
2001function _createFeatureReducers(injector, reducerCollection) {
2002 /** @type {?} */
2003 const reducers = reducerCollection.map((/**
2004 * @param {?} reducer
2005 * @return {?}
2006 */
2007 (reducer) => {
2008 return reducer instanceof InjectionToken ? injector.get(reducer) : reducer;
2009 }));
2010 return reducers;
2011}
2012/**
2013 * @param {?} initialState
2014 * @return {?}
2015 */
2016function _initialStateFactory(initialState) {
2017 if (typeof initialState === 'function') {
2018 return initialState();
2019 }
2020 return initialState;
2021}
2022/**
2023 * @param {?} metaReducers
2024 * @param {?} userProvidedMetaReducers
2025 * @return {?}
2026 */
2027function _concatMetaReducers(metaReducers, userProvidedMetaReducers) {
2028 return metaReducers.concat(userProvidedMetaReducers);
2029}
2030/**
2031 * @param {?} store
2032 * @return {?}
2033 */
2034function _provideForRootGuard(store) {
2035 if (store) {
2036 throw new TypeError(`StoreModule.forRoot() called twice. Feature modules should use StoreModule.forFeature() instead.`);
2037 }
2038 return 'guarded';
2039}
2040
2041/**
2042 * @fileoverview added by tsickle
2043 * Generated from: src/reducer_creator.ts
2044 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2045 */
2046/**
2047 * Return type of the `on` fn.
2048 * Contains the action reducer coupled to one or more action types.
2049 * @record
2050 * @template State, Creators
2051 */
2052function ReducerTypes() { }
2053if (false) {
2054 /** @type {?} */
2055 ReducerTypes.prototype.reducer;
2056 /** @type {?} */
2057 ReducerTypes.prototype.types;
2058}
2059/**
2060 * @record
2061 * @template State, Creators
2062 */
2063function OnReducer() { }
2064/**
2065 * \@description
2066 * Associates actions with a given state change function.
2067 * A state change function must be provided as the last parameter.
2068 *
2069 * \@usageNotes
2070 * ```ts
2071 * on(AuthApiActions.loginSuccess, (state, { user }) => ({ ...state, user }))
2072 * ```
2073 * @template State, Creators
2074 * @param {...?} args `ActionCreator`'s followed by a state change function.
2075 *
2076 * @return {?} an association of action types with a state change function.
2077 *
2078 */
2079function on(...args) {
2080 // This could be refactored when TS releases the version with this fix:
2081 // https://github.com/microsoft/TypeScript/pull/41544
2082 /** @type {?} */
2083 const reducer = (/** @type {?} */ (args.pop()));
2084 /** @type {?} */
2085 const types = (/** @type {?} */ (((/** @type {?} */ (((/** @type {?} */ (((/** @type {?} */ (args)))))).map((/**
2086 * @param {?} creator
2087 * @return {?}
2088 */
2089 (creator) => creator.type)))))));
2090 return { reducer, types };
2091}
2092/**
2093 * \@description
2094 * Creates a reducer function to handle state transitions.
2095 *
2096 * Reducer creators reduce the explicitness of reducer functions with switch statements.
2097 *
2098 * \@usageNotes
2099 *
2100 * - Must be used with `ActionCreator`'s (returned by `createAction`). Cannot be used with class-based action creators.
2101 * - The returned `ActionReducer` should additionally be wrapped with another function, if you are using View Engine AOT.
2102 * In case you are using Ivy (or only JIT View Engine) the extra wrapper function is not required.
2103 *
2104 * **Declaring a reducer creator**
2105 *
2106 * ```ts
2107 * export const reducer = createReducer(
2108 * initialState,
2109 * on(
2110 * featureActions.actionOne,
2111 * featureActions.actionTwo,
2112 * (state, { updatedValue }) => ({ ...state, prop: updatedValue })
2113 * ),
2114 * on(featureActions.actionThree, () => initialState);
2115 * );
2116 * ```
2117 *
2118 * **Declaring a reducer creator using a wrapper function (Only needed if using View Engine AOT)**
2119 *
2120 * ```ts
2121 * const featureReducer = createReducer(
2122 * initialState,
2123 * on(
2124 * featureActions.actionOne,
2125 * featureActions.actionTwo,
2126 * (state, { updatedValue }) => ({ ...state, prop: updatedValue })
2127 * ),
2128 * on(featureActions.actionThree, () => initialState);
2129 * );
2130 *
2131 * export function reducer(state: State | undefined, action: Action) {
2132 * return featureReducer(state, action);
2133 * }
2134 * ```
2135 * @template S, A
2136 * @param {?} initialState Provides a state value if the current state is `undefined`, as it is initially.
2137 * @param {...?} ons Associations between actions and state changes.
2138 * @return {?} A reducer function.
2139 *
2140 */
2141function createReducer(initialState, ...ons) {
2142 /** @type {?} */
2143 const map = new Map();
2144 for (let on of ons) {
2145 for (let type of on.types) {
2146 /** @type {?} */
2147 const existingReducer = map.get(type);
2148 if (existingReducer) {
2149 /** @type {?} */
2150 const newReducer = (/**
2151 * @param {?} state
2152 * @param {?} action
2153 * @return {?}
2154 */
2155 (state, action) => on.reducer(existingReducer(state, action), action));
2156 map.set(type, newReducer);
2157 }
2158 else {
2159 map.set(type, on.reducer);
2160 }
2161 }
2162 }
2163 return (/**
2164 * @param {?=} state
2165 * @param {?=} action
2166 * @return {?}
2167 */
2168 function (state = initialState, action) {
2169 /** @type {?} */
2170 const reducer = map.get(action.type);
2171 return reducer ? reducer(state, action) : state;
2172 });
2173}
2174
2175/**
2176 * @fileoverview added by tsickle
2177 * Generated from: src/index.ts
2178 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2179 */
2180
2181/**
2182 * @fileoverview added by tsickle
2183 * Generated from: public_api.ts
2184 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2185 */
2186
2187/**
2188 * @fileoverview added by tsickle
2189 * Generated from: index.ts
2190 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2191 */
2192
2193/**
2194 * @fileoverview added by tsickle
2195 * Generated from: ngrx-store.ts
2196 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2197 */
2198
2199export { ActionsSubject, FEATURE_REDUCERS, INIT, INITIAL_REDUCERS, INITIAL_STATE, META_REDUCERS, REDUCER_FACTORY, ReducerManager, ReducerManagerDispatcher, ReducerObservable, STORE_FEATURES, ScannedActionsSubject, State, StateObservable, Store, StoreFeatureModule, StoreModule, StoreRootModule, UPDATE, USER_PROVIDED_META_REDUCERS, USER_RUNTIME_CHECKS, combineReducers, compose, createAction, createFeatureSelector, createReducer, createReducerFactory, createSelector, createSelectorFactory, defaultMemoize, defaultStateFn, isNgrxMockEnvironment, on, props, reduceState, resultMemoize, select, setNgrxMockEnvironment, union, STORE_PROVIDERS as ɵb, createActiveRuntimeChecks as ɵba, createSerializationCheckMetaReducer as ɵbb, createImmutabilityCheckMetaReducer as ɵbc, createInNgZoneCheckMetaReducer as ɵbd, provideRuntimeChecks as ɵbe, checkForActionTypeUniqueness as ɵbf, _runtimeChecksFactory as ɵbg, _actionTypeUniquenessCheck as ɵbh, ACTIONS_SUBJECT_PROVIDERS as ɵc, REDUCER_MANAGER_PROVIDERS as ɵd, SCANNED_ACTIONS_SUBJECT_PROVIDERS as ɵe, isEqualCheck as ɵf, STATE_PROVIDERS as ɵg, _ROOT_STORE_GUARD as ɵh, _INITIAL_STATE as ɵi, _REDUCER_FACTORY as ɵj, _INITIAL_REDUCERS as ɵk, _STORE_REDUCERS as ɵl, _FEATURE_REDUCERS as ɵm, _FEATURE_CONFIGS as ɵn, _STORE_FEATURES as ɵo, _FEATURE_REDUCERS_TOKEN as ɵp, _RESOLVED_META_REDUCERS as ɵq, _USER_RUNTIME_CHECKS as ɵr, _ACTIVE_RUNTIME_CHECKS as ɵs, _ACTION_TYPE_UNIQUENESS_CHECK as ɵt, _createStoreReducers as ɵu, _createFeatureStore as ɵv, _createFeatureReducers as ɵw, _initialStateFactory as ɵx, _concatMetaReducers as ɵy, _provideForRootGuard as ɵz };
2200//# sourceMappingURL=ngrx-store.js.map