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.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

ntt_command_service-1.0.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ntt-command-service-1.0.2.tar.gz
  • Upload date:
  • Size: 3.9 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.2.tar.gz
Algorithm Hash digest
SHA256 c36e0dd2a3a4441da7cf20572a635ab3b4723691121b0a0be8fdf1039374ba80
MD5 baa2bb3dbf3482723b815863c46da646
BLAKE2b-256 08a0b399f330ef23211cdece2dcef098c69b6b1d39d8819898f38e68f60ea443

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ntt_command_service-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 09a2483f3d787e641d8c0fb046e1e8c0c96512fa01b24e229cf655e9695529c4
MD5 e9651ab581b79cab3b306deec98cdb22
BLAKE2b-256 380b147336acc7fff1583bb4d003745a8e6b5f309f1d5f1d319f81e94a6148fb

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