Skip to content

When does a node become dead? #2140

Discussion options

You must be logged in to vote

Hey @aniket-banyal - I have a few ideas that might be helpful

One specific case you missed in your list

Let's say you have three levels in a tree:

  1. The root of the tree knows about a company
  2. The company knows about an employee, which is an instance of a Person node
  3. The root's company gets changed into a new company with a different Person. The original Person is now dead (this example got more morbid than I expected).

Here's code to that effect:

import { types } from "mobx-state-tree";

(async function () {
  const Person = types.model("Person", {
    name: types.string,
  });

  const Company = types.model("Company", {
    name: types.string,
    employee: Person,
  });

  const RootStore 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aniket-banyal
Comment options

Answer selected by aniket-banyal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants