{"action":"created","issue":{"url":"https://api.github.com/repos/acdlite/redux-actions/issues/68","repository_url":"https://api.github.com/repos/acdlite/redux-actions","labels_url":"https://api.github.com/repos/acdlite/redux-actions/issues/68/labels{/name}","comments_url":"https://api.github.com/repos/acdlite/redux-actions/issues/68/comments","events_url":"https://api.github.com/repos/acdlite/redux-actions/issues/68/events","html_url":"https://github.com/acdlite/redux-actions/issues/68","id":134490372,"number":68,"title":"identity function in createAction only handles the first parameter","user":{"login":"killermonk","id":1088866,"avatar_url":"https://avatars.githubusercontent.com/u/1088866?v=3","gravatar_id":"","url":"https://api.github.com/users/killermonk","html_url":"https://github.com/killermonk","followers_url":"https://api.github.com/users/killermonk/followers","following_url":"https://api.github.com/users/killermonk/following{/other_user}","gists_url":"https://api.github.com/users/killermonk/gists{/gist_id}","starred_url":"https://api.github.com/users/killermonk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/killermonk/subscriptions","organizations_url":"https://api.github.com/users/killermonk/orgs","repos_url":"https://api.github.com/users/killermonk/repos","events_url":"https://api.github.com/users/killermonk/events{/privacy}","received_events_url":"https://api.github.com/users/killermonk/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/acdlite/redux-actions/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-02-18T06:04:23Z","updated_at":"2016-06-27T03:44:21Z","closed_at":null,"body":"The `createAction` function returns an action creator with the signature `function(...args)`. However, if you do not pass an `actionCreator` method to the `createAction` function, then the \"`identity`\" function is used.\r\n\r\nThe `identity` function is this: `(t) => t`, which does not do an argument spread and, since it is called with function.apply, it only handles the first argument passed in to the action creator, even though the action creator is designed around supporting n arguments."},"comment":{"url":"https://api.github.com/repos/acdlite/redux-actions/issues/comments/228648327","html_url":"https://github.com/acdlite/redux-actions/issues/68#issuecomment-228648327","issue_url":"https://api.github.com/repos/acdlite/redux-actions/issues/68","id":228648327,"user":{"login":"calvinnwq","id":580008,"avatar_url":"https://avatars.githubusercontent.com/u/580008?v=3","gravatar_id":"","url":"https://api.github.com/users/calvinnwq","html_url":"https://github.com/calvinnwq","followers_url":"https://api.github.com/users/calvinnwq/followers","following_url":"https://api.github.com/users/calvinnwq/following{/other_user}","gists_url":"https://api.github.com/users/calvinnwq/gists{/gist_id}","starred_url":"https://api.github.com/users/calvinnwq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calvinnwq/subscriptions","organizations_url":"https://api.github.com/users/calvinnwq/orgs","repos_url":"https://api.github.com/users/calvinnwq/repos","events_url":"https://api.github.com/users/calvinnwq/events{/privacy}","received_events_url":"https://api.github.com/users/calvinnwq/received_events","type":"User","site_admin":false},"created_at":"2016-06-27T03:44:21Z","updated_at":"2016-06-27T03:44:21Z","body":"I personally do `(arg1, arg2) => ({ arg1, arg2 })` if i have arguments to pass.\r\nEven if it were a single argument, I'd still do `(arg1) => ({ arg1 })` just to keep it consistent and make it more readable in the reducers, especially in larger apps.\r\n\r\ne.g.\r\n```javascript\r\n// action\r\nconst actions = {\r\n  entry: {\r\n    add: createAction('ADD_ENTRY', (entry) => ({ entry })),\r\n  }\r\n};\r\n// reducer\r\n[actions.entry.add]: (state, payload) => ({\r\n    ...state,\r\n    entry: [\r\n      ...state.entry,\r\n      payload.entry,\r\n    ],\r\n  }),\r\n```\r\n\r\nSince I pass my own payloadCreator all the time, I don't encounter the problem as discussed here.\r\n\r\nAlso, since JavaScript does not have support for named parameters like in some other languages e.g. python where you can specify `functionName(arg1=1, arg2=2)`, you can pass an object literal as your only argument.\r\n\r\n```javascript\r\nconst addEntry = createAction('ADD_ENTRY'),\r\nconst entry = { name: 'entry name' };\r\naddEntry({ entry }); // same as addEntry({ entry: entry });\r\n```\r\n\r\n***\r\n\r\nI don't really agree with passing multiple arguments as an array as payload, since you'd have to again assume the order of the arguments passed which makes code less readable and less flexible.\r\n\r\nBut, not passing all arguments is bad as well as it restricts by default, so I'd say the solution mentioned by @yangmillstheory above is sufficient."}}
{"actor":{"display_login":"calvinnwq"}}