Metadata-Version: 2.4
Name: streamlit-state-manager
Version: 0.2.6
Summary: A wrapper around Streamlit's session state for easier state management
Author-email: Stelios Georgaras <steliosgp13@gmail.com>
License: Apache License 2.0
Project-URL: Homepage, https://github.com/steliosgrs/streamlit-state-manager
Project-URL: Bug Tracker, https://github.com/steliosgrs/streamlit-state-manager/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: streamlit>=1.30.0
Dynamic: license-file

# Streamlit State Manager

The Streamlit State Manager `StateManager` is essentially a wrapper around [Streamlit's](https://github.com/streamlit/streamlit) native `st.session_state` dictionary, that simplifies how you interact with it.

## Features

1. **Cleaner Code**: Reduces boilerplate for initialization and access
2. **Error Prevention**: Reduces common pitfalls like missing initialization

## Installation

```bash
pip install streamlit-state-manager
```

## Examples

### 1. Simplified Access Patterns

**Without StateManager:**

```python
# Check if exists, initialize, then get
if "counter" not in st.session_state:
    st.session_state["counter"] = 0
count = st.session_state["counter"]

# Updating value
st.session_state["counter"] += 1
```

**With StateManager:**

```python
# Get with auto-initialization
count = StateManager.get("counter", 0)

# Updating value
StateManager.set("counter", count + 1)
```

### 2. Prevention of Common Errors

**Without StateManager:**

```python
# Potential KeyError if key doesn't exist
value = st.session_state["maybe_missing_key"]

# Forgetting to check existence before using
st.session_state["counter"] += 1  # Error if counter doesn't exist
```

**With StateManager:**

```python
# Safe access with optional default
value = StateManager.get("maybe_missing_key", default_value=None)
```

## License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
