Repository-Metriken
- Stars
- (191 Stars)
- PR-Merge-Metriken
- (PR-Metriken ausstehend)
Beschreibung
its currently difficult to manage arrays with only a set and get method.
irecord.set('arr', ['bob','tim','terry'] );
this will give us an immutable object with an immutably list at key 'arr'. we can use the set API to get to certain indices of the array, but if we want to push, pop or splice anything new, we at best can manually set a new index or overwrite an old one.
updateIn
If we expose the updateIn method, the user could reach the array, and apply a transform method. The entirety of irecord would still work as a getter/setter. I dont see a lot of downside except that its more complex than a simple value based getter/setter.
irecordThing.updateIn( 'keyThatGetsArray', function(arr) {
arr.push( 'newThing' )
return arr;
});
push, pop, splice etc
If we're very set on not exposing updateIn, then we could consider mapping some array methods that internally use updateIn. This would match the getter/setter api and OOP feeling of not using a transform method.
irecordThing.set( 'keyThatGetsAnArray' ).push( 'newThing' );