-
Notifications
You must be signed in to change notification settings - Fork 12
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
48 allow update before remove #71
Conversation
@luoto that is great work 👍 And I love that you also updated the comments for the docs, I tend to forget that myself all the time :) I think we can simplify the code a little. For example, you call Maybe you can also reuse the utils/change-object.js method to apply the optional For example, we could leave the function remove (objectsOrIds, change) {
return Array.isArray(objectsOrIds) ?
updateMany.call(this, objectsOrIds.map(markAsDeleted.bind(null, change))) :
updateOne.call(this, markAsDeleted(change, objectsOrIds))
} That way we have a single method that gets called separately on every object / id, no matter if we got an array or not. Then in the I've made a gist of the I really hope that the my guidance is helpful, please let me know if there is any way I could do better, it's a first-timer for me as well ;) |
@gr2m Here is what I came up with your guidance. It is very similar to what you had. Which is so much more elegant than what I had originally.. haha. Thank you so much for your time. I recognize that this could be taking up a lot of it, and I will use it as wisely as I can :). Trust me, I have already learned so much in this process so far. For this refactored version, I kept thinking to myself, 'wow this is so slick!'. I will have to try use to these ternary operators and functional style of programming more often, and of course code reuse ;) I also noticed from the slack chats that you do some pair programming with some of the other contributors. Maybe I could sit in some time just to observe and learn more about the project? In the end, lets go with what you had in your gist because to me, it looks more consistent with the project. I'm going to make the changes and update the PR for your review. Thanks. |
@luoto just to butt in: never worry about 'taking up time', Hoodie is for everyone and if we didn't talk to/help people we would not be Hoodie :D |
@luoto wow you really came very close to my solution, that is a very good sign, must be good then :) Can you update your PR then? |
258c292
to
c6023ec
Compare
Welcome to the open source community @luoto :-D |
Thanks @kentcdodds :). It feels great to be a part of something greater. Time to hunt down and work on another issue, huzzah! ;) |
👍 |
🎉 nice one @luoto 💃 |
Here is how I thought to solve this problem:
remove
, thenremove
will either extend it with a the property_deleted: true
, or put a thin wrapper around it, which appends the_deleted: true
property to the object before it gets passed into the actual change function._deleted: true
will be appended to each of theobjectsOrIds
before they are sent off to the update functions without the change parameters, allowing them to update and 'delete' properly.I also updated the function signature to accept an optional change argument and made changes to the documentation to reflect that.
closes #48