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

Uploaded Source

Built Distribution

ntt_command_service-1.0.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ntt-command-service-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 d6dd4ad4c27d655c9b3acc832b476d890bb41a1717cf60f87f3b9cb7f5da62eb
MD5 dfabfaf2367d899b2d65ca2368f490b2
BLAKE2b-256 b14b9a21020acb061d4b66109138ee32d1507d8bd3461e43d5156c2d8e4cbd9c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ntt_command_service-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 556e29abfdb0c805b32ac72afcdab1b48aec64708d2c9d4b2436749453ff5f6a
MD5 11352f01ec57fd7cb844a4334ddb551a
BLAKE2b-256 094177f2769318a1d7111a38d8f1c57019cfb24c15684681a5351902bf58096d

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