{"id":15201832,"url":"https://github.com/ioweyou/iou-core","last_synced_at":"2025-10-02T18:30:53.984Z","repository":{"id":57737986,"uuid":"56619798","full_name":"ioweyou/iou-core","owner":"ioweyou","description":"IOU is a Promises/A+ compliant promise library for Java","archived":true,"fork":false,"pushed_at":"2017-03-02T07:35:11.000Z","size":200,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-17T04:08:06.489Z","etag":null,"topics":["android","aplus","deferred","gradle","iou","java","java7","java8","promise"],"latest_commit_sha":null,"homepage":"https://ioweyou.github.io","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/ioweyou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-19T18:05:21.000Z","updated_at":"2023-01-28T09:52:03.000Z","dependencies_parsed_at":"2022-08-24T15:00:45.729Z","dependency_job_id":null,"html_url":"https://github.com/ioweyou/iou-core","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ioweyou%2Fiou-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ioweyou%2Fiou-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ioweyou%2Fiou-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ioweyou%2Fiou-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ioweyou","download_url":"https://codeload.github.com/ioweyou/iou-core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235031436,"owners_count":18925234,"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":["android","aplus","deferred","gradle","iou","java","java7","java8","promise"],"created_at":"2024-09-28T03:41:27.088Z","updated_at":"2025-10-02T18:30:53.608Z","avatar_url":"https://github.com/ioweyou.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IOU Core\n\n[![Travis CI](https://travis-ci.org/ioweyou/iou-core.svg)](https://travis-ci.org/ioweyou/iou-core)\n[![Coverage Status](https://coveralls.io/repos/github/ioweyou/iou-core/badge.svg?branch=master)](https://coveralls.io/github/ioweyou/iou-core?branch=master)\n[![License MIT](https://img.shields.io/:license-mit-blue.svg)](http://badges.mit-license.org)\n\n\u003ca href=\"https://promisesaplus.com/\"\u003e\n    \u003cimg src=\"https://promisesaplus.com/assets/logo-small.png\" alt=\"Promises/A+ logo\"\n         title=\"Promises/A+ 1.0 compliant\" align=\"right\" /\u003e\n\u003c/a\u003e\nA [Promises/A+](https://github.com/promises-aplus/promises-spec) compliant promise library for Java, designed to be extended by other libraries like [IOU Java](https://github.com/ioweyou/iou-java) and [IOU Android](https://github.com/ioweyou/iou-android).\n\n#### Table Of Contents\n\n[Implementations](#implementations)\n\n[Dependency management](#dependency-management)\n  * [Maven](#maven)\n  * [Gradle](#gradle)\n\n[Examples](#examples)\n  * [Call with single then](#call-with-single-then)\n  * [Call with single then and Java 8 lambda](#call-with-single-then-and-java-8-lambda)\n  * [Chained or piped promise](#chained-or-piped-promise)\n  * [Parallel promise](#parallel-promise)\n  * [Rejecting a promise](#rejecting-a-promise)\n  * [Failing a promise](#failing-a-promise)\n\n## Implementations\n* [IOU Java](https://github.com/ioweyou/iou-java)\n* [IOU Android](https://github.com/ioweyou/iou-android)\n\n## Dependency management\n### Maven\n-----\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003enl.brusque.iou\u003c/groupId\u003e\n    \u003cartifactId\u003eiou-core\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0-beta-01\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\n-----\n```\ncompile 'nl.brusque.iou:iou-core:1.0.0-beta-01'\n```\n\n## Examples\n-----\n### Given the example implementation\n```java\nclass TestTypedIOU\u003cTInput\u003e extends AbstractIOU\u003cTInput\u003e {\n  ...\n}\n\nclass TestTypedPromise\u003cTInput\u003e extends AbstractPromise\u003cTInput\u003e {\n  ...\n}\n\nTestTypedIOU\u003cInteger\u003e iou = new TestTypedIOU\u003c\u003e();\n\n```\n### Call with single then\n```java\niou.getPromise()\n    .then(new IThenCallable\u003cInteger, Void\u003e() {\n        @Override\n        public Void apply(Integer integer) throws Exception {\n            System.out.println(integer);\n\n            return null;\n        }\n    });\n\niou.resolve(42); // prints 42\n```\n### Call with single then and Java 8 lambda\n```java\niou.getPromise()\n    .then((Integer integer) -\u003e {\n        System.out.println(integer);\n\n        return null;\n    });\n\niou.resolve(42); // prints 42\n```\n### Chained or piped promise\n```java\niou.getPromise()\n    .then(new IThenCallable\u003cInteger, Integer\u003e() {\n        @Override\n        public Integer apply(Integer input) throws Exception {\n            return input * 10;\n        }\n    })\n    .then(new IThenCallable\u003cInteger, String\u003e() {\n        @Override\n        public String apply(Integer input) throws Exception {\n            return String.format(\"The result: %d\", input);\n        }\n    })\n    .then(new IThenCallable\u003cString, Void\u003e() {\n        @Override\n        public Void apply(String input) throws Exception {\n            System.out.println(input);\n\n            return null;\n        }\n    });\n\niou.resolve(42); // prints \"The result: 420\"\n```\n### Sequential promise\n```java\nTestTypedPromise\u003cInteger\u003e promise = iou.getPromise();\n\npromise\n    .then(new IThenCallable\u003cInteger, Void\u003e() {\n        @Override\n        public Void apply(Integer input) throws Exception {\n            System.out.println(input);\n\n            return null;\n        }\n    });\n\npromise\n    .then(new IThenCallable\u003cInteger, String\u003e() {\n        @Override\n        public Void apply(Integer input) throws Exception {\n            String result = String.format(\"%d * 10 = %d\", input, input * 10);\n            System.out.println(result);\n\n            return result;\n        }\n    });\n\niou.resolve(42); // prints \"42\" and \"42 * 10 = 420\" in exactly this order\n```\n### Rejecting a promise\n```java\niou.getPromise()\n    .then(new IThenCallable\u003cInteger, Integer\u003e() {\n        @Override\n        public Integer apply(Integer integer) throws Exception {\n            return integer * 42;\n        }\n    }, new IThenCallable\u003cObject, Void\u003e() {\n        @Override\n        public Void apply(Object reason) throws Exception {\n            System.out.println(String.format(\"%s I can't do that.\", reason));\n\n            return null;\n        }\n    });\n\niou.reject(\"I'm sorry, Dave.\"); // prints \"I'm sorry, Dave. I can't do that.\"\n```\n### Failing a promise\n```java\niou.getPromise()\n    .then(new IThenCallable\u003cInteger, Integer\u003e() {\n        @Override\n        public Integer apply(Integer input) throws Exception {\n            throw new Exception(\"I just don't care.\");\n        }\n    })\n    .then(new IThenCallable\u003cInteger, Void\u003e() {\n        @Override\n        public Void apply(Integer input) throws Exception {\n            System.out.println(\"What would you say it is you do here?\");\n\n            return null;\n        }\n    }, new IThenCallable\u003cObject, Void\u003e() {\n        @Override\n        public Void apply(Object reason) throws Exception {\n            System.out.println(\n              String.format(\"It's not that I'm lazy, it's that %s\",\n                ((Exception)reason).getMessage()));\n\n            return null;\n        }\n    });\n\niou.resolve(42); // prints \"It's not that I'm lazy, it's that I just don't care.\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fioweyou%2Fiou-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fioweyou%2Fiou-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fioweyou%2Fiou-core/lists"}