mobx-utils
mobx-utils copied to clipboard
Util for mapping an observable array into view models.
I keep finding myself in a situation, where I need to keep in sync (create/update/delete/move) an array of models (AKA VMs, Classes, factory functions) - with some observable array.
Is there some util of generic solution for that for MobX?
- A similar Solid.js solution: mapArray.
- Related discussion.
Which direction? Maybe a autorun(() => { someObservableArray.forEach(x => update(vm, x)) }
suffices?
@NaridaL, Both directions: When a new item (with a new ID) returned from API - a new VM should be created. When a VM is deleted - the same item in the observable array should be delete.
Same for update, create, move...
autorun(() => { someObservableArray.forEach(x => update(vm, x)) }
won't suffice. Thanks.
@danielyogel Did you find a solution to this?