{"id":18869055,"url":"https://github.com/feelschaotic/delayaction","last_synced_at":"2025-07-20T19:33:44.702Z","repository":{"id":130582190,"uuid":"128065326","full_name":"feelschaotic/DelayAction","owner":"feelschaotic","description":"The design and implementation of the target method pretest model. 目标方法前置检验模型设计与实现，应用于所有需要在目标操作前插入N个前置验证条件的情况（如：登录后自动执行关注、登录后继续上次的发帖操作）","archived":false,"fork":false,"pushed_at":"2019-07-06T08:06:20.000Z","size":138,"stargazers_count":21,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-21T11:07:11.456Z","etag":null,"topics":["design-patterns"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/feelschaotic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-04-04T13:22:33.000Z","updated_at":"2021-11-05T07:09:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"ba05ad71-1201-4af3-a390-7f253d813570","html_url":"https://github.com/feelschaotic/DelayAction","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/feelschaotic/DelayAction","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feelschaotic%2FDelayAction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feelschaotic%2FDelayAction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feelschaotic%2FDelayAction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feelschaotic%2FDelayAction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/feelschaotic","download_url":"https://codeload.github.com/feelschaotic/DelayAction/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feelschaotic%2FDelayAction/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266187298,"owners_count":23889955,"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":["design-patterns"],"created_at":"2024-11-08T05:15:37.402Z","updated_at":"2025-07-20T19:33:44.697Z","avatar_url":"https://github.com/feelschaotic.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## DelayAction 目标方法前置检验模型\r\n\r\n### 一、需求背景\r\n在执行目标行为时，需要执行一些前置的行为。而这些前置行为，需要用户参与才能完成。例如：未登录情况下点击关注用户，跳转登陆，登陆成功后自动执行关注。\r\n\r\n\r\n### 二、如何使用\r\n\r\n- 无嵌套调用（常用场景，单Action）：\r\n\r\n`ActionActivity`实现`Action`接口，或 new `Action`实现类，实现 call 目标行为。\r\n\r\n```\r\nSingleCall.getInstance()\r\n          .addAction(ActionActivity.this)\r\n          .addValid(new LoginValid())//前置条件，可能有多个\r\n          .addValid(new OtherValid()\r\n          .doCall();\r\n```\r\n前置行为完成后，调用`SingleCall.getInstance().doCall();`启动验证模型\r\n\r\n- 嵌套调用（多Action）：\r\n```\r\nCall call1 = new Call(new Action() {\r\n    @Override\r\n    public void call() {\r\n    }\r\n});\r\nCall call2 = new Call(new Action() {\r\n    @Override\r\n    public void call() {\r\n    }\r\n});\r\ncallUnit1.addValid(new LoginValid());\r\ncallUnit1.addValid(new AnotherValid());\r\ncallUnit2.addValid(new OtherValid());\r\n\r\nMultipleCall.getInstance()\r\n        .postCall(call1)\r\n        .postCall(call2);\r\n```\r\n前置行为完成后，调用`MultipleCall.getInstance().reCheckValid();`启动验证模型\r\n\r\n### 三、架构设计\r\n![类关系图](https://upload-images.jianshu.io/upload_images/3167794-af92e0f102172d59.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)\r\n\r\n\u003e[详细博文介绍请戳](https://www.jianshu.com/p/7114d5e82e8c)\r\n\r\n\r\n\u003e 本项目在 [jinyb09017](https://github.com/jinyb09017/delayActionDemo) 大大的基础上完善\r\n\u003e- 增加了容错处理\r\n\u003e- 补充了嵌套 Call 的情况\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeelschaotic%2Fdelayaction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffeelschaotic%2Fdelayaction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeelschaotic%2Fdelayaction/lists"}