-
Couldn't load subscription status.
- Fork 42
Description
🌟 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
- Improve
typecheck on subclass ofPayloadfix(almin): Payload subclass need to define "type" property #296
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
- Remove deprecated
Context#on*API Almin: lifecyle method in UseCaseExectutor will be deprecated. #206 - Remove deprecated
ChangedPayloadchore(almin): Deprecate ChangedPayload #285
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.