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

Genotype snapshot feature #144

Open
gliechtenstein opened this issue Jul 9, 2017 · 1 comment
Open

Genotype snapshot feature #144

gliechtenstein opened this issue Jul 9, 2017 · 1 comment

Comments

@gliechtenstein
Copy link
Contributor

Cell attaches a data structure called Genotype to each node to allow each node to manage its own state in a decentralized manner.

So if you take any node created by Cell, and query its Genotype you'll get the "blueprint" of the node. For example you create a node like this:

c = {
  $cell: true,
  id: "item",
  $text: "Hello world",
  _update(message) {
    this.$text = message;
  }
}

and query it like this:

console.log(document.querySelector("#item").Genotype)

This is pretty useful for debugging since the Genotype object updates in realtime to keep the state of each node.

However, there's a limitation to the current implementation. Currently Cell wraps all the functions with Nucleus.bind() to make sure each time a function is called it gets added to the Nucleus._queue and the diff logic is triggered when the call stack becomes empty.

This means when I do something like

console.log(document.querySelector("#item").Genotype._update)

it will print the wrapper function that's returned by Nucleus.bind(), not the original function.

Need to find a way to retrieve each function's original form instead of the bound function so it's completely stateless and reusable.

@gliechtenstein
Copy link
Contributor Author

So far have gotten this far #145

It works, but gonna try to sleep on this and see if it feels right in terms of naming, API, and the overall way it works.

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