{"comment":{"url":"https://api.github.com/repos/danschultz/dedux/comments/13717739","html_url":"https://github.com/danschultz/dedux/commit/09a769aeb4a11ae59c34001c37a779429b3d982a#commitcomment-13717739","id":13717739,"user":{"login":"astashov","id":12795,"avatar_url":"https://avatars.githubusercontent.com/u/12795?v=3","gravatar_id":"","url":"https://api.github.com/users/astashov","html_url":"https://github.com/astashov","followers_url":"https://api.github.com/users/astashov/followers","following_url":"https://api.github.com/users/astashov/following{/other_user}","gists_url":"https://api.github.com/users/astashov/gists{/gist_id}","starred_url":"https://api.github.com/users/astashov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astashov/subscriptions","organizations_url":"https://api.github.com/users/astashov/orgs","repos_url":"https://api.github.com/users/astashov/repos","events_url":"https://api.github.com/users/astashov/events{/privacy}","received_events_url":"https://api.github.com/users/astashov/received_events","type":"User","site_admin":false},"position":11,"line":11,"path":"example/reddit/views/app/effects.dart","commit_id":"09a769aeb4a11ae59c34001c37a779429b3d982a","created_at":"2015-10-12T14:05:20Z","updated_at":"2015-10-12T14:05:20Z","body":"What about having `Effects` as classes, in the same way as we do for `Actions`? Functions are too anonymous, and hard to debug because of that, with classes we at least can check `runtimeType`, or even reimplement `toString()` (or use your fancy `Inspectable` mixin :)). Something like this:\r\n\r\n```dart\r\nabstract class Effect<S> {\r\n  Future<Null> apply(Channel<Action> actions, S state);\r\n}\r\n\r\nclass FetchPostsEffect implements Effect<State> {\r\n  final String term;\r\n  FetchPostsEffect(this.term);\r\n\r\n  Future<Null> apply(Channel<Action> actions, State state) async {\r\n    actions.add(new SearchAction(term));\r\n\r\n    var response = await HttpRequest.getString(\"https://www.reddit.com/r/$term.json\");\r\n    var json = JSON.decode(response);\r\n    actions.add(new FetchedPostsAction(json[\"data\"][\"children\"]));\r\n  }\r\n}\r\n```"}}