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
Built Distribution
File details
Details for the file ntt-command-service-1.0.4.tar.gz
.
File metadata
- Download URL: ntt-command-service-1.0.4.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2c6fed89cdfb84c44fd6c2dd3aca9eabe412a6823c676137df27bc01c827d92 |
|
MD5 | 4f5467e24c6ecdd9dc99b84a7f985353 |
|
BLAKE2b-256 | e6be485b938b2f24bccfedaf83c573fd1d53df5fd92d057f891ec97263e10198 |
File details
Details for the file ntt_command_service-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: ntt_command_service-1.0.4-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c35f26a84f7c8f32907ed096677fa46170a1f9f6ce296d3baf2294108f603392 |
|
MD5 | dc857477b26821e2f04b09571ec70931 |
|
BLAKE2b-256 | c92a47e0442aa6950c0e63c0cae2296c74e23a402f9a90eef5c3e55a16d4ec1e |