Almin

Almin

  • Docs
  • API
  • Blog
  • Help
  • GitHub

›API

Introduction

  • Getting Started
  • Components of Almin
  • Principles
  • Hello World

Tutorial

  • Example projects
  • Counter Tutorial
  • Todo App tutorial

Guides

  • Logging
  • Nesting UseCase
  • Performance profile
  • Strict mode
  • UseCase LifeCycle
  • TypeScript

Troubleshooting

  • UseCase is already released

Appendix

  • GLOSSARY

API

  • API Index
  • Context
  • Dispatcher
  • DispatcherPayloadMeta
  • LifeCycleEventHub
  • Store
  • StoreGroup
  • UseCase
  • UseCaseContext
  • UseCaseExecutor
Edit

UseCaseContext

Interface

export declare class UseCaseContext {
    useCase(useCase: UseCaseFunction): UseCaseExecutor<FunctionalUseCase>;
    useCase<T extends UseCaseLike>(useCase: T): UseCaseExecutor<T>;
}

export declare class UseCaseContext {

Maybe, UseCaseContext is invisible from Public API.

UseCase#context return UseCaseContext insteadof Context. It has limitation as against to Context. Because, UseCaseContext is for UseCase, is not for Context.

class ParentUseCase extends UseCase {
    execute() {
        this.context; // <= This is a instance of UseCaseContext
    }
}

Interface

useCase(useCase: UseCaseFunction): UseCaseExecutor<FunctionalUseCase>;
    useCase<T extends UseCaseLike>(useCase: T): UseCaseExecutor<T>;

Create UseCaseExecutor for useCase.

It can be used for transaction between UseCases.

Example

ParentUseCase execute ChildUseCase. It is called Nesting UseCase.

// Parent -> ChildUseCase
export class ParentUseCase extends UseCase {
    execute() {
        // `this.context` is a instance of UseCaseContext.
        return this.context.useCase(new childUseCase()).execute();
    }
}

export class ChildUseCase extends UseCase {
    execute() {
        this.dispatch({
            type: "ChildUseCase"
        });
    }
}

← UseCaseUseCaseExecutor →
Almin
Docs
Getting StartedTutorialAPI Reference
Community
User ShowcaseStack OverflowTwitter
GitHub
GitHubReleasesIssuesStar
Copyright © 2021 azu