fuzetsu / mergerino

immutable merge util for state management
MIT License
71 stars 6 forks source link

consider copying prototype when merging #6

Open fuzetsu opened 5 years ago

fuzetsu commented 5 years ago

As discussed here: https://gitter.im/foxdonut/meiosis?at=5d9647e65173c33ca161959d

Would be useful when you need to manage data that has special methods defined in its prototype and you would like to preserve that while using mergerino.

ChambreNoire commented 4 years ago

I believe this is the source of my problem when using mergerino in conjunction with meiosis-setup and union-type. If I place a union-type in meiosis state and update it later (via a mergerino merge), the union-type methods like case/caseOn are lost. :(

fuzetsu commented 4 years ago

Interesting 😄

That's a solid use case. Do you mind confirming if the version of mergerino on that branch solves the problem (https://github.com/fuzetsu/mergerino/pull/7)

The only thing preventing me from merging it is probably unfounded concerns about performance loss, and questions about use cases.

I find it nice to keep a serializable state, but complex objects like union-type don't really fit that bill. I feel like I'd usually try to keep those separate from state in some way, but I guess enforcing that is not really mergerino's job so expanding to cover this kind of use case should be fine.