{"id":18019268,"url":"https://github.com/andytill/pure-controllers","last_synced_at":"2025-04-04T16:28:24.904Z","repository":{"id":13168572,"uuid":"15851587","full_name":"andytill/pure-controllers","owner":"andytill","description":"Pure controllers brings the best of pure functions to JavaFX controllers: Testability","archived":false,"fork":false,"pushed_at":"2014-01-12T21:49:33.000Z","size":140,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T02:13:16.736Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andytill.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-12T21:46:25.000Z","updated_at":"2014-05-30T04:34:43.000Z","dependencies_parsed_at":"2022-08-29T23:30:21.335Z","dependency_job_id":null,"html_url":"https://github.com/andytill/pure-controllers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andytill%2Fpure-controllers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andytill%2Fpure-controllers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andytill%2Fpure-controllers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andytill%2Fpure-controllers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andytill","download_url":"https://codeload.github.com/andytill/pure-controllers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208659,"owners_count":20901603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T05:09:40.798Z","updated_at":"2025-04-04T16:28:24.889Z","avatar_url":"https://github.com/andytill.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n#Pure Controllers\n\nPure controllers brings pure functions\\* and functional programming to JavaFX controllers.  Instead of making database calls and causing other side effects directly from event handler methods in a controller, the controller returns data describing the IO action that should take place and the pure Controllers library will route it to a command you provide. \n\nThis makes unit testing very simple.  Instead of mocking services inside the controller, unit tests can assert the returned IO objects without actually executing them.\n\nIO routing is performed using Guice.  Controllers returning IO must be created using a Guice injector.\n\n##Getting Started\n\nLets setup the Guice `Module` that will route our IO requests, to commands.  The `Email` class is the IO that will describe the email and `EmailService` will send the email.\n\n    public class DemoModule extends PureControllersModule {\n        @Override\n        protected void bindCommands(CommandHQ commandHQ) {\n            commandHQ.addCommand(Email.class, new EmailService());\n        }\n    }\n\n`CommandHQ` is a map of Class objects to commands.  It can apply an IO object to it's corresponding command.  Now we can define the FXML event handler which will get called when the user presses the button to send an email.\n\n    @FXML\n    @IOProvider\n    public Email onSendEmailButtonClicked() {\n        return new Email(\"kittyburrito@googlemail.com\", \"Hi There!\");\n    }\n\nMethods annotated with `@IOProvider` must return data describing a command.  Pure Controllers will intercept this command using dependency injection and run it using a command registered to handle the `Email` class.\n\nSee the demo included in the source for more details on how to setup an application using pure controllers.\n\n**\\* The pure controllers library allows controllers to maintain state and refer to object fields to keep things simple. Functions are not completely pure, unless you want it to be!**\n\n##License\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Andy Till\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandytill%2Fpure-controllers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandytill%2Fpure-controllers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandytill%2Fpure-controllers/lists"}