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

Feature/parcel node #248

Merged
merged 7 commits into from Aug 13, 2019
Merged

Conversation

dxinteractive
Copy link
Collaborator

@dxinteractive dxinteractive commented Aug 12, 2019

Addresses #246

dataparcels

  • BREAKING CHANGE remove Parcel.move()
    • Instead you can use unmutable's move() with asNodes() like this: parcel.update(asNodes(move(a,b)))
  • Add dataparcels/asNodes
  • Add dataparcels/ParcelNode

react-dataparcels

  • Add react-dataparcels/asNodes
  • Add react-dataparcels/ParcelNode

The asNodes function is a kind of parcel updater that allows for adding, removing and re-arranging child values.

It must be passed a function, whose first argument will be your Parcel’s value, but with all child values replaced with ParcelNode instances. You can move and remove these as you like. You can also insert non-ParcelNode values into the parent data shape to set new data. The function passed to asShape() will also sometimes receive a ChangeRequest as a second parameter depending on what the asNodes() function is being passed into.

let parcel = new Parcel({
    value: [1,2,3]
});

// reverse the parcel's children
parcel.update(asNodes(
    shape => shape.slice().reverse() // clones and reverses the shape array
));

// new value is [3,2,1]

A lighter alternative to ParcelShape that is intended to be used to edit
objects and arrays, and can work with unmutable functions. Also hopefully
can be used internally as a replacement for many of the parcelData array functions
@dxinteractive dxinteractive merged commit 93ed772 into release/cumbersome-crocodile Aug 13, 2019
@dxinteractive dxinteractive deleted the feature/parcel-node branch August 15, 2019 13:47
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.

None yet

2 participants