Skip to main content

Small library for observation mechanism

Project description

ntt-command-service

Library for implementing Command Pattern

Examples

from ntt_command_service import *
from typing import List

fScores: List[float] = []

class AppendDataCommand(ICommand):
    def __init__(self, fScores: List[float], fScore: float):
        self._fScores = fScores
        self._fScore = fScore

    def Execute(self) -> None:
        self._fScores.append(self._fScore)

    def CanExecute(self) -> bool:
        return True

    def Undo(self) -> None:
        self._fScore.pop()

serCommandService = CommandService()
serCommandService.AddCommand(AppendDataCommand(fScores, 3))
# ----> fScores = [3]
serCommandService.AddCommand(AppendDataCommand(fScores, 5))
# ----> fScores = [3, 5]
serCommandService.AddCommand(AppendDataCommand(fScores, 1))
# ----> fScores = [3, 5, 1]
serCommandService.Undo()
# ----> fScores = [3, 5]
serCommandService.Clear()
serCommandService.CanUndo()
# ----> False

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ntt-command-service-1.0.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

ntt_command_service-1.0.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file ntt-command-service-1.0.0.tar.gz.

File metadata

  • Download URL: ntt-command-service-1.0.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for ntt-command-service-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f32189726f75cfbf7a833d02038f87d7653c18617167078456758fcc7fd6792d
MD5 315e814b7dec0649415bdae8ee4c8966
BLAKE2b-256 3dcac8c96397b0f80f0d46c5979bd52021ed2fabd2174ac03dde33a92d3cecb1

See more details on using hashes here.

File details

Details for the file ntt_command_service-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ntt_command_service-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8794d784522534b4f9798ba90688e7ca40123271ece0864749094dbdbb77b21
MD5 09f2ff81e5ab0d8652cc2cdf320b3ac6
BLAKE2b-256 14fc5d864b56c8fc039450cc7cfe7bfff60cb4545007cfdad97c80765045c612

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page