Skip to content

Commit

Permalink
fix: redux support
Browse files Browse the repository at this point in the history
  • Loading branch information
satanTime committed Jan 2, 2021
1 parent 6f50cee commit 9142b12
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
15 changes: 12 additions & 3 deletions src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ class ReduceFlat {
constructor(public readonly data: any, public readonly selector: ENTITY_SELECTOR) {}
}

const reduceFlat = (payload: {data: any; selector: ENTITY_SELECTOR}) => new ReduceFlat(payload.data, payload.selector);
// Because of redux it can't be a ReduceGraph instance.
const reduceFlat = (payload: {data: any; selector: ENTITY_SELECTOR}) => ({
data: payload.data,
selector: payload.selector,
type: ngrxEntityRelationshipActions.reduceFlat,
});
reduceFlat.type = ngrxEntityRelationshipActions.reduceFlat;

class ReduceGraph {
Expand All @@ -20,8 +25,12 @@ class ReduceGraph {
constructor(public readonly data: any, public readonly selector: ENTITY_SELECTOR) {}
}

const reduceGraph = (payload: {data: any; selector: ENTITY_SELECTOR}) =>
new ReduceGraph(payload.data, payload.selector);
// Because of redux it can't be a ReduceGraph instance.
const reduceGraph = (payload: {data: any; selector: ENTITY_SELECTOR}) => ({
data: payload.data,
selector: payload.selector,
type: ngrxEntityRelationshipActions.reduceGraph,
});
reduceGraph.type = ngrxEntityRelationshipActions.reduceGraph;

export {ReduceFlat, reduceFlat, ReduceGraph, reduceGraph};
4 changes: 2 additions & 2 deletions test/store/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('store/actions', () => {
const data = Symbol();
const selector = rootEntity(() => undefined);
const actual = reduceFlat({data, selector});
expect(actual).toEqual(jasmine.any(ReduceFlat));
expect(actual).not.toEqual(jasmine.any(ReduceFlat));
expect(actual).toEqual(
jasmine.objectContaining({
type: ngrxEntityRelationshipActions.reduceFlat,
Expand Down Expand Up @@ -54,7 +54,7 @@ describe('store/actions', () => {
const data = Symbol();
const selector = rootEntity(() => undefined);
const actual = reduceGraph({data, selector});
expect(actual).toEqual(jasmine.any(ReduceGraph));
expect(actual).not.toEqual(jasmine.any(ReduceGraph));
expect(actual).toEqual(
jasmine.objectContaining({
type: ngrxEntityRelationshipActions.reduceGraph,
Expand Down
4 changes: 1 addition & 3 deletions tslint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ rules:
export-name: false
forin: true
function-constructor: true
function-name:
- true
- static-method-regex: "^forRoot|[A-Z_\\\\d]+$"
function-name: false
import-name: false
increment-decrement: true
insecure-random: false
Expand Down

0 comments on commit 9142b12

Please sign in to comment.