Skip to content

Fractal Store behavior on array properties #496

Open
@SilverSN95

Description

@SilverSN95

This is a...

  • feature request
  • bug report
  • usage question

What toolchain are you using for transpilation/bundling?

  • @angular/cli

Environment

Angular Version: 5
@angular-redux/store version: latest
@angular/cli version: 1.5.2

Expected Behaviour:

Using a fractal store on a property of Array type should return updated state as an Array type.

Actual Behaviour:

The new state is returned as an object map where the key is the array index of the object from the original array.

Additional Notes:

Our configuration is almost identical to what is outlined in the fractal-store documentation, but instead of 'users' being an object map using a userId key we are using an array and the array index to access the object. Is this an incorrect use case?
Specifically, the transformation appears to happen in the setIn function. I think this test may demonstrate what we are seeing:

  fit('performs a deeply nested set correctly without mutation', () => {
    const original = {
      a: 1,
      b: {
        c: []
      }
    };
    const expected = {
      a: 1,
      b: {
        c: [{ d: 2 }]
      },
    };

    expect(setIn(original, ['b', 'c', 0], { d: 2 })).toEqual(expected);
    expect(original).toEqual({ a: 1, b: {c: []} });
  });

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions