Giter Club home page Giter Club logo

Comments (8)

JanMalch avatar JanMalch commented on August 18, 2024 1

developmentMode recursively freezes the state. While the state after every action should be a new one, the action handlers use mutability while applying their logic. This is my guess.
I will look into it.

from entity-state.

JanMalch avatar JanMalch commented on August 18, 2024

What kind of entities do you have on your store? Can you paste your state class, including @State annotation?

from entity-state.

kuhnroyal avatar kuhnroyal commented on August 18, 2024

As far as I can tell, there is nothing special about it.
The model is just a plain object.

@State<EntityStateModel<IFoo>>({
  name: "foos",
  defaults: defaultEntityState()
})
export class FooState extends EntityState<IFoo> {

  constructor() {
    super(FooState, "id", UUIDV1IdGenerator);
  }

  onUpdate(current: Readonly<IFoo>, updated: Partial<IFoo>): IFoo {
    return {...current, ...updated};
  }
}

The error message seems to indicate, that the problem happens when the entities map is updated.

core.js:15714 ERROR TypeError: Cannot add property 930ec024-e23c-4d3a-91bd-619a6dbe7c0a, object is not extensible
    at ngxs-labs-entity-state.js:1107
    at Array.forEach (<anonymous>)
    at FooState.push../node_modules/@foo/ngxs-labs-entity-state/fesm5/ngxs-labs-entity-state.js.EntityState._addOrReplace (ngxs-labs-entity-state.js:1103)
    at FooState.push../node_modules/@foo/ngxs-labs-entity-state/fesm5/ngxs-labs-entity-state.js.EntityState.add (ngxs-labs-entity-state.js:777)
    at StateFactory.push../node_modules/@ngxs/store/fesm5/ngxs-store.js.StateFactory.invokeActions (ngxs-store.js:1475)
    at MergeMapSubscriber.project (ngxs-store.js:1401)

from entity-state.

JanMalch avatar JanMalch commented on August 18, 2024

What does IFoo look like?

from entity-state.

kuhnroyal avatar kuhnroyal commented on August 18, 2024

It doesn't really matter, some interface with a id: string and whatever else you want to add.
The problem occurs when an entity gets added to the entities HashMap after EntityState.add is invoked.

It would be good if there were some alpha/beta releases on NPM, didn't manage to add this stackblitz atm.

from entity-state.

kuhnroyal avatar kuhnroyal commented on August 18, 2024

@JanMalch This is fixed with #98?

from entity-state.

JanMalch avatar JanMalch commented on August 18, 2024

It will be, as soon as the refactor/immutability branch is merged. It was planned to develop the entity state operators (#85) in there aswell. But I will create a PR for the branch now and open a new one for state operators.

from entity-state.

matodrobec avatar matodrobec commented on August 18, 2024

Hello @JanMalch @splincode ,
Can you update npm "@ngxs-labs/entity-state". I am getting the error.

Thank you

from entity-state.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.