Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Almin 0.15.0 #287

@azu

Description

@azu

🌟 Features

Almin: Add UseCase#shouldExecute #292 #298

What it UseCase#shouldExecute?

Currently, the user can not prevent to execute of UseCase by declaratory.
Also, almin-logger does log the execute, but this usecase is not executed actually,

class MyUseCase extends UseCase {
    execute(args){
        if(condition){
             return false; // if this usecase should not execute
        }
        // do something
    }
}

The user can prevent to execute of UseCase by declaratory.
This UseCase#shouldExecute allow to write following.

class MyUseCase extends UseCase {
    shouldExecute(args): boolean {
         return false; // if this usecase should not execute
    }
    execute(args){
        // do something
    }
}

If shouldExecute return false, almin-logger does not log the execution of the UseCase.
But, you can observe this log by onWillNotExecuteEachUseCase handler.

For more details, see LifeCycleEventHub · Almin.

🔥 Breaking Change

TypeScript

Before:

// OK
class P1 extends Payload{
    type = "P1"
}
// OK
class P2 extends Payload {
    type: string;
    constructor() {
        super({ type: "P2" });
    }
}
// OK
class P3 extends Payload{
    constructor() {
        super({ type: "P2" });
    }
}
// OK - It is a bug
class P4 extends Payload{
    // no type
}

After:

If you have inherited Payload class, should have defined type property.

// OK
class P1 extends Payload{
    type = "P1"
}
// OK
class P2 extends Payload {
    type: string;
    constructor() {
        super({ type: "P2" });
    }
}
// NG - Need to defined `type: string`
class P3 extends Payload{
    constructor() {
        super({ type: "P2" });
    }
}
// NG: Fix a bug #295 
class P4 extends Payload{
    // no type
}

♻️ Remove deprecated API

You can migrate this deprecated API to new API by @almin/migration-tools.

How to migrate?

Run following command and select x.x.x → 0.15.x

npm install -g @almin/migration-tools
almin-migration-tools "src/**/*.js"

What is changed?

ChangedPayload has been removed.

import { UseCase, ChangedPayload } from "almin";

export class ExampleUseCase extends UseCase {
    execute() {
        this.context.useCase(new ChangedPayload()).execute();
    }
}

to

import { UseCase } from "almin";

export class ExampleUseCase extends UseCase {
    execute() {
        this.context.useCase({ type: "ChangedPayload" }).execute();
    }
}

For more information, see @almin/migration-tools.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions