Skip to content
This repository was archived by the owner on Jul 8, 2021. It is now read-only.

Commit b97a9b8

Browse files
author
Austin McDaniel
committed
fix: effects materialize
1 parent cc55383 commit b97a9b8

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 3.1.6 - 2/27/18
2+
- Fix: Effects materialize vs take
3+
14
# 3.1.5 - 2/27/18
25
- Fix: Effects not unsubscribing
36

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngrx-actions",
3-
"version": "3.1.5",
3+
"version": "3.1.6",
44
"description": "Actions and Reducer Utility Library for NGRX",
55
"main": "dist/index.js",
66
"scripts": {

src/factory.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Action } from '@ngrx/store';
22
import { NGRX_ACTIONS_META, StoreMetadata } from './internals';
33
import { NgrxSelect } from './select';
4-
import { take } from 'rxjs/operators';
4+
import { take, materialize } from 'rxjs/operators';
55

66
export function createReducer<TState = any>(
77
store:
@@ -39,11 +39,9 @@ export function createReducer<TState = any>(
3939
const retVal = instance[effectMeta.fn](state, action);
4040
if (retVal) {
4141
if (retVal.subscribe) {
42-
retVal.pipe(take(1)).subscribe(res => {
43-
if (Array.isArray(res)) {
44-
res.forEach(r => NgrxSelect.store && NgrxSelect.store.dispatch(r));
45-
} else if (NgrxSelect.store) {
46-
NgrxSelect.store.dispatch(res);
42+
retVal.pipe(materialize()).subscribe(res => {
43+
if (res.value && NgrxSelect.store) {
44+
NgrxSelect.store.dispatch(res.value);
4745
}
4846
});
4947
} else if (NgrxSelect.store) {

0 commit comments

Comments
 (0)