Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RemoveData & RemoveChildData not firing change #33

Open
jaichandra opened this issue Mar 7, 2018 · 0 comments
Open

RemoveData & RemoveChildData not firing change #33

jaichandra opened this issue Mar 7, 2018 · 0 comments

Comments

@jaichandra
Copy link

Im getting used to this library now.. Thanks for creating this. But, I see that my observables are not fired when I remove data. Not sure if Im doing anything wrong here. AddData fires my observables (this.store.select), but the same doesn't fire when I use RemoveData or RemoveChildData.

Here's what Im trying to do:

Say I have the following data:

export class User {
  id: number;
  name: string;
  tasks: Task[];
}

export class Task {
  id: number;
  name: string;
  comments: Comment[];
}

export class Comment{
  id: number;
  text: string;
}

export const userSchema = new schema.Entity('users');
export const commentSchema = new schema.Entity('comments');
export const taskSchema = new schema.Entity('tasks', { comments: [commentSchema] });

Once I use AddData, I get below normalized data

users: [
  "1": {
    id: "1",
    name: 'Example Task',
    tasks: ["2"]
  }
],
tasks: [
  "2": {
    id: "2",
    name: 'Example Task',
    comments: ["4"]
  }
],
comments: [
  "4": {
    id: "4",
    text: "My Comment",
  }
]

Now, if I want to remove a task from the data and use RemoveChildData({id: "2", taskSchema, userSchema, parentId: "1" }), I can see that it removes the task and reference from the tasks property under users.
If I use RemoveData({id: "2", schema: taskSchema, removeChildren: {comments: 'comments'}}), I see that the task and the related comments are removed.

But in both cases, my this.store.select is not fired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant