GithubHelp home page GithubHelp logo

feelschaotic / delayaction Goto Github PK

View Code? Open in Web Editor NEW
21.0 2.0 4.0 138 KB

The design and implementation of the target method pretest model. 目标方法前置检验模型设计与实现,应用于所有需要在目标操作前插入N个前置验证条件的情况(如:登录后自动执行关注、登录后继续上次的发帖操作)

Java 100.00%
design-patterns

delayaction's Introduction

DelayAction 目标方法前置检验模型

一、需求背景

在执行目标行为时,需要执行一些前置的行为。而这些前置行为,需要用户参与才能完成。例如:未登录情况下点击关注用户,跳转登陆,登陆成功后自动执行关注。

二、如何使用

  • 无嵌套调用(常用场景,单Action):

ActionActivity实现Action接口,或 new Action实现类,实现 call 目标行为。

SingleCall.getInstance()
          .addAction(ActionActivity.this)
          .addValid(new LoginValid())//前置条件,可能有多个
          .addValid(new OtherValid()
          .doCall();

前置行为完成后,调用SingleCall.getInstance().doCall();启动验证模型

  • 嵌套调用(多Action):
Call call1 = new Call(new Action() {
    @Override
    public void call() {
    }
});
Call call2 = new Call(new Action() {
    @Override
    public void call() {
    }
});
callUnit1.addValid(new LoginValid());
callUnit1.addValid(new AnotherValid());
callUnit2.addValid(new OtherValid());

MultipleCall.getInstance()
        .postCall(call1)
        .postCall(call2);

前置行为完成后,调用MultipleCall.getInstance().reCheckValid();启动验证模型

三、架构设计

类关系图

详细博文介绍请戳

本项目在 jinyb09017 大大的基础上完善

  • 增加了容错处理
  • 补充了嵌套 Call 的情况

delayaction's People

Contributors

feelschaotic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

delayaction's Issues

Valid应在docall内再precheck一次

Valid应在doCall内再preCheck一次
假设场景:未登录的用户先是addvalid到Call对象,然后通过其他途径登录。此时已经是登录态了。但是docall的时候没有检测登录态还是执行未登录的操作。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.