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

WIP: Abstract away data access/cloning/mutation/etc., add in some laziness #10

Open
wants to merge 67 commits into
base: master
Choose a base branch
from

Conversation

jdeal
Copy link
Owner

@jdeal jdeal commented Oct 26, 2017

There's still a lot of cleanup to do here, but the basic pieces are in place now.

The goals here are:

  • Move all the raw property access, object cloning, mutations, etc. into one place to reduce the complexity of some navigators and core traversal.
  • Because of that abstraction, make it easier to possibly add in support for iterables in a later PR.
  • Make some operations lazy and remove some crazy code put in place for performance edges. For example, instead of "looking ahead" to see if a slice is actually going to be used, now a slice is a lazy wrapper that gets sent to the next stage. The slice only ever occurs if the slice is actually resolved to a value.
  • Because of that, make it possible to add in other laziness later, making it more efficient to define complex navigators in terms of multiple other navigators. This is possible now, but because of intermediary cloning and mutation, it's sometimes far more efficient to make a special case navigator.
  • Make some operations more homogenous across different structures. You can now slice an object. You can now get the nth element of an object. Things like that are easier with a base set of data wrappers.

It was really hard to do all this and keep everything as performant (at least for simple cases). So there's lots of funny business going on in src/utils/data.js. I even use some macros to inline code in a few places. 😬 Ultimately, I think the extra complexity in one place is worth the reduced complexity and increased flexibility in other places.

Still todo:

  • Write lots more tests.
  • Add back in some comments that were stripped out while rewriting some sections.
  • Maybe make src/utils/data.js a little more DRY.
  • Clean things up. Probably some dead code, incorrect comments, etc. laying around now.
  • Maybe make things more efficient by removing unnecessary unwrap calls in some cases by marking some navigators as able to accept wrapped data.
  • ?

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

Successfully merging this pull request may close these issues.

1 participant