101
101 copied to clipboard
"Push" method
Maybe we could have an immutable push (and unshift?) method.
Before
return put(state, 'data', [
...state.data,
action.payload
])
After
return push(state, 'data', action.payload)
I've been using 101
recently in my newer projects, and I've been meaning to have something like this.
Not sure if it's "bloat", but let me know what you think. I can send a PR if you think this sounds good.
I was thinking of creating an invoke method that may satisfy your needs:
invoke(state, 'data.push', action.payload)
Although that would not me an immutable helper. We may be able to create an immutable invoke as well. I've been wanting to reorganize 101 into pairs of helper (immutable and not).
Let me know your thoughts
invoke
sounds cool. I'm not sure how to name it, but I presume that people won't use both immutable and mutable invoke at the same time, so maybe we could do:
// Mutable
const invoke = require('101/invoke')
// Immutable
const invoke = require('101/invoke-immutable')