Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax: simplify launch script #14

Open
louisdussarps opened this issue Aug 6, 2024 · 1 comment
Open

Syntax: simplify launch script #14

louisdussarps opened this issue Aug 6, 2024 · 1 comment

Comments

@louisdussarps
Copy link
Contributor

louisdussarps commented Aug 6, 2024

Today, if you want to be able to start an action, you 've to :

  • define the action
  • register the action in an app
  • bootstrap the app and wait for the app to be ready
    Then you can resume the action.

Most simple example is thus :

@bootstrapApp({
    db : {
        mongo: {
            url: dbUrl
        }
    }
})
export class ExampleApp extends ActionApp{
    declare = [CiPipeline, PrintAction, WaitAction]
}


ActionApp.waitForActiveApp.then(()=>{
    console.log("waitforactive app")
    ActionApp.activeApp.ActionModel.findOne({
        filter : {
            main : true
        }
    }).then((actionDb)=>{
        console.log("actionDbFinding")
        if(actionDb){
            const pipeline = Action.constructFromDb(actionDb);
            return pipeline.resume();
        }
        
        //create main action
        const pipeline = new CiPipeline();
        pipeline.setFilter({
            main : true
        })
        pipeline.dbDoc.save();
    })
})

We want this to be shorten

@louisdussarps
Copy link
Contributor Author

One solution can be, in order to remove the app part, to use decorator :
On every action, we would do :

@registerAction
export class MyAction extends Action{
}

Then on the index file, we would only need to do :

new App({url : ....})

const myAction = new MyAction();
myAction.resume();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant