Giter VIP home page Giter VIP logo

Comments (6)

Yomguithereal avatar Yomguithereal commented on September 27, 2024 1

Hello @luccitan. Normally, baobab is not meant to hold anything else than "raw" data. Classes aren't therefore supported as it is quite impossible to reliably clone an instance in every JS engine. There are ways to kinda fake cloning instance but they might have some undesirable side effects.

From here, you have another option, if you really want to keep classes: you can disable the tree's persistence (and hence lose its advantages but, it can be done if persistence is not what you need).

var tree = new Baobab({}, {persistent: false});

If you do so, baobab will only mutate objects given and won't try to shift references along the path by cloning.

from baobab.

Yomguithereal avatar Yomguithereal commented on September 27, 2024 1

Yes you can. It just means you won’t get pure rendering performance gain (which you dont have by default anyway).

from baobab.

luccitan avatar luccitan commented on September 27, 2024

It works wonderfully! πŸ‘

Can you explain a little bit more the persistent option please ?
I have read through its documentation in the README but I didn't think it was the solution of my problem.

I would appreciate further information about its usefulness, as I may need the tree's history later. (It's not a concern at the moment)

from baobab.

Yomguithereal avatar Yomguithereal commented on September 27, 2024

Persistence is basically useful for 2 use cases:

  1. You need to track the history of the data and may want to go back in time easily.
  2. You need to be able to determine whether two states of the data are identical or not based only on referential equality === without having to perform a diff.

from baobab.

Yomguithereal avatar Yomguithereal commented on September 27, 2024

No. 2 is very useful with view engines like React that can beneficiate from shouldComponentUpdate callbacks that can just check whether references are identical to be able to take the decision to render again or not.

from baobab.

luccitan avatar luccitan commented on September 27, 2024

Does that mean that I can't use baobab-react with a Baobab tree without persistence ? πŸ€”

from baobab.

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.