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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ntt-command-service-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 45f761e0ca479c30f427518b82471d50c80abf3251bc847a14a0df6978e6a66a
MD5 01be983685a8033ba6143c89dd0f9bf6
BLAKE2b-256 8d3f347359d10bd1bc7ffbaf30ad7f0d87d3efb9ba27c84236e9d1684a88030a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ntt_command_service-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 26a9898558330dab9b4d482a8afe4194834d06566d9e6c503a9db9a3d9ac0859
MD5 5669be939401488c939a0fa4f613ad9a
BLAKE2b-256 cf6ce0994b0e350cf2963095976801e40cbe0dd0ed1c2c9529a3a182b05696ed

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