Skip to content
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

"Push" method #153

Open
srph opened this issue Apr 13, 2017 · 2 comments
Open

"Push" method #153

srph opened this issue Apr 13, 2017 · 2 comments

Comments

@srph
Copy link
Contributor

srph commented Apr 13, 2017

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.

@tjmehta
Copy link
Owner

tjmehta commented Apr 16, 2017

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

@srph
Copy link
Contributor Author

srph commented Apr 25, 2017

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')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants