CommitStore¶
- class dsviper.CommitStore¶
Bases:
objectA high-level application class used to implement the store, dispatch, undo/redo and notification concepts inspired by the redux approach.
The implementation used a Commit database for the persistence layer.
- attachment_getting() AttachmentGetting¶
Return the AttachmentGetting interface of the current state or raise.
- can_redo() bool¶
Return True if the store can redo.
- can_undo() bool¶
Return True if the store can undo.
- clear_undo_redo() None¶
clear the undo redo stack.
- close() None¶
Close the database.
- commit_mutations(label: str, commit_mutable_state: CommitMutableState) None¶
Commit the mutations tracked by the mutable state.
- database() CommitDatabase¶
Return the database or raise.
- definitions() DefinitionsConst¶
Return the definitions.
- delete_commit(commit_id: ValueCommitId) None¶
Delete a commit.
WARNING: It’s not a feature!, it’s a trick used during interactive presentation.
- disable_commit(commit_id: ValueCommitId) None¶
Disable a commit.
- dispatch(label: str, callable: Callable, *args) None¶
Dispatch a callable.
- dispatch_diff(label: str, attachment: Attachment, key: ValueKey, value: _InputValues, *, recursive: bool = False) None¶
Dispatch a mutating diff(…).
- dispatch_enable_commit(commit_id: ValueCommitId, enabled: bool) None¶
Dispatch the act of enabling/disabling a commit.
- dispatch_set(label: str, attachment: Attachment, key: ValueKey, value: _InputValues) None¶
Dispatch a mutating set(…).
- dispatch_update(label: str, attachment: Attachment, key: ValueKey, path: PathConst, value: _InputValues) None¶
Dispatch a mutating update(…).
- enable_commit(commit_id: ValueCommitId) None¶
Enable a commit.
- extend_definitions(definitions: DefinitionsConst) DefinitionsExtendInfo¶
Extend the database definitions and notify.
- forward() None¶
Move to the most plausible head.
- has_database() bool¶
Return true there is a database.
- has_state() bool¶
Return true there is a state.
- static instance() CommitStore¶
Return the singleton.
- merge_commit(commit_id: ValueCommitId) None¶
Merge a commit.
- mutable_state() CommitMutableState¶
Return a new mutable state for the current state.
- notifier() CommitStoreNotifying | None¶
Return the notifier or None.
- notify_database_did_close() None¶
Send a notification to inform that the database was closed.
- notify_database_did_open() None¶
Send a notification to inform that the database was opened.
- notify_database_did_reset() None¶
Send a notification to inform that the database did reset.
- notify_database_will_reset() None¶
Send a notification to inform that the database will reset.
- notify_definitions_did_change() None¶
Send a notification to inform that the definitions has changed.
- notify_dispatch_error(error: Error) None¶
Send a notification to inform that an error occurred during a dispatch.
- notify_reset_database() None¶
Send a notification to reset the database.
- notify_state_did_change() None¶
Send a notification to inform that the current state has changed.
- notify_stop_live() None¶
Send a notification to stop the live mode.
- redo() None¶
Implement the undo idiom for a Commit database.
- reduce_heads() None¶
Reduce to a single head by iteratively merging heads, starting from the last_commit_id.
- reset() None¶
Remove all commits except the first one.
WARNING: It’s not a feature!, it’s a trick used during interactive presentation.
- reset_undo_redo() None¶
Reset the undo redo stack.
- set_database(commit_database: CommitDatabase) None¶
set the database.
- set_notifier(notifier: CommitStoreNotifying) None¶
Set the notifier.
- set_state(commit_state: CommitState) None¶
set the state.
- state() CommitState | None¶
Return the current state or raise.
- undo() None¶
Implement the undo idiom for a Commit database.
- undo_stack_ids() tuple[list[ValueCommitId], int | None]¶
Return (commit_ids, current_commit_id).
- use(commit_database: CommitDatabase) None¶
Use a Commit database.
- use_commit(commit_id: ValueCommitId) None¶
Use a commit.