{"action":"created","issue":{"url":"https://api.github.com/repos/hyperapp/hyperapp/issues/67","repository_url":"https://api.github.com/repos/hyperapp/hyperapp","labels_url":"https://api.github.com/repos/hyperapp/hyperapp/issues/67/labels{/name}","comments_url":"https://api.github.com/repos/hyperapp/hyperapp/issues/67/comments","events_url":"https://api.github.com/repos/hyperapp/hyperapp/issues/67/events","html_url":"https://github.com/hyperapp/hyperapp/issues/67","id":206342623,"number":67,"title":"Pass parameters to effects functions?","user":{"login":"zaceno","id":2061445,"avatar_url":"https://avatars.githubusercontent.com/u/2061445?v=3","gravatar_id":"","url":"https://api.github.com/users/zaceno","html_url":"https://github.com/zaceno","followers_url":"https://api.github.com/users/zaceno/followers","following_url":"https://api.github.com/users/zaceno/following{/other_user}","gists_url":"https://api.github.com/users/zaceno/gists{/gist_id}","starred_url":"https://api.github.com/users/zaceno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaceno/subscriptions","organizations_url":"https://api.github.com/users/zaceno/orgs","repos_url":"https://api.github.com/users/zaceno/repos","events_url":"https://api.github.com/users/zaceno/events{/privacy}","received_events_url":"https://api.github.com/users/zaceno/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-02-08T22:18:30Z","updated_at":"2017-02-08T22:39:42Z","closed_at":null,"body":"I am trying to build a simple login form with hyperapp. You are either already logged in, in which case you get a link to log out, or you are not logged in, in which case you get a username/password form.\r\n\r\nNow to do the actual authentication of the username & password via the backend, I need to use an effect (asynchronous operation). But since effects don't take any parameters (as per the docs), and only have access to the model, that means I need to store the currently input username & password in my model. To achieve this, I must use reducers bound to oninput in each field. Just so I know i have the latest input value available to the login-effect, when it is called (in the onsubmit event of the form tag)\r\n\r\nTwo problems with this, that the ability to pass parameters to effects (just like you can for reducers), would solve:\r\n\r\n1) What the user types in the input & password fields is a temporary state. Those slots in the model aren't relevant once the user has logged in, and it seems wasteful to allocate space in the model for something that will only be relevant before the user is logged in. (And if they are already logged in, those slots will never be used)\r\n\r\n2) I don't really need the username/passwords in the model for any other reason. I'm just using the model to carry the values into the login-effect. So it seems a waste of computing power to have to update the model every time a key is typed, when all i really care about is what the values of the fields are at the time the user presses submit.\r\n"},"comment":{"url":"https://api.github.com/repos/hyperapp/hyperapp/issues/comments/278485738","html_url":"https://github.com/hyperapp/hyperapp/issues/67#issuecomment-278485738","issue_url":"https://api.github.com/repos/hyperapp/hyperapp/issues/67","id":278485738,"user":{"login":"tunnckoCore","id":5038030,"avatar_url":"https://avatars.githubusercontent.com/u/5038030?v=3","gravatar_id":"","url":"https://api.github.com/users/tunnckoCore","html_url":"https://github.com/tunnckoCore","followers_url":"https://api.github.com/users/tunnckoCore/followers","following_url":"https://api.github.com/users/tunnckoCore/following{/other_user}","gists_url":"https://api.github.com/users/tunnckoCore/gists{/gist_id}","starred_url":"https://api.github.com/users/tunnckoCore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tunnckoCore/subscriptions","organizations_url":"https://api.github.com/users/tunnckoCore/orgs","repos_url":"https://api.github.com/users/tunnckoCore/repos","events_url":"https://api.github.com/users/tunnckoCore/events{/privacy}","received_events_url":"https://api.github.com/users/tunnckoCore/received_events","type":"User","site_admin":false},"created_at":"2017-02-08T22:39:42Z","updated_at":"2017-02-08T22:39:42Z","body":"> But since effects don't take any parameters (as per the docs)\r\n\r\nThat's not true. Every action can be passed with arguments, actually single `data` argument, through the views. It is easy as `msg.action(data)`. If you want to call other effect from some effect you can do it too.\r\n\r\n```js\r\napp({\r\n  effects: {\r\n    foo: (model, msg, data, done) => {\r\n      msg.bar({ bar: data.bar + model.bar + ' from foo' })\r\n    },\r\n    bar: (model, msg, data, done) => console.log(data)\r\n  }\r\n})\r\n```\r\n"}}
{"actor":{"display_login":"tunnckoCore"}}