-
Notifications
You must be signed in to change notification settings - Fork 28
Records support #9
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
Conversation
3d320b5
to
3125f67
Compare
Excellent work! will dive in and review now. Let me know if you wont have time to follow up, and I can probably finish myself in that case. |
@@ -61,3 +61,21 @@ Convert a JSON representation back into an immutable object | |||
### `transit.withFilter(function) => transit` | |||
|
|||
Create a modified version of the transit API that deeply applies the provided filter function to all immutable collections before serialising. Can be used to exclude entries. | |||
|
|||
### `transit.withRecords([recordClasses], optionalFilterFunction) => transit` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be tempted to leave out the filter argument, but allow withRecords(records).withFilter(filter)
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah a fluent API like that makes more sense to me as well, I just left it this way because it's how @thomasboyt implemented it. I can change it though.
Let me know if any of that is unclear, and feel free to disagree! 😄 |
8dc0b05
to
2dcf14b
Compare
Ok think I've covered everything you brought up. I'll open a PR on immutableJS for the recordName thing, but I don't think it's worth waiting on that to get this functionality merged. |
2dcf14b
to
5df01c9
Compare
@@ -61,3 +61,21 @@ Convert a JSON representation back into an immutable object | |||
### `transit.withFilter(function) => transit` | |||
|
|||
Create a modified version of the transit API that deeply applies the provided filter function to all immutable collections before serialising. Can be used to exclude entries. | |||
|
|||
### `transit.withRecords([recordClasses])[.withFilter(function)] => transit` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think it would be straightforward to generalise so that these can be used in either order - and shrink down to only one place for creating the public API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm sure there's a good way to do that. It's getting late here in Spain and my brain stops working so well. :P Let me think about the best way to implement this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After further consideration and a bit of experimentation I haven't found a way I'm happy with to make this work while both preserving the existing semantics and not complicating the code internally. That doesn't mean it isn't possible, just that I don't see the way to do it. 😄 Given how infrequently I suspect someone will want to both set a filter and deal with Records, and given that the current solution works just fine, I'm inclined to leave it how it is right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, I might take a crack at this myself - I think there should be a way to achieve this and end up with less code 😄
Nice work on this, that was fast! |
5df01c9
to
acec0f5
Compare
Hey, would you mind cutting a new release with this functionality? I need it available so I can make a PR for another module in my dependency chain, thanks. |
This PR adds record support as discussed in #7. It's based on the work by @thomasboyt in his fork, with a few modifications:
filter
such as Map (covered in the tests).I think this covers everything @glenjamin asked for to merge a PR; if there's anything else necessary I'm happy to make changes!