Metadata-Version: 2.4
Name: state-handler
Version: 0.1.0
Summary: A simple global state manager to help pass values through mautiple py files
Author: OneNorth Technologies
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENCE
Dynamic: license-file

# State Handler

A lightweight global state manager for Python.

---

## Features

* Simple global key-value storage
* Accessible across your entire Python project
* Lightweight and dependency-free
* Event callbacks on state changes
* Optional persistence support

---

## Installation

```bash
pip install state-handler
```

---

## Quick Start

```python
from state_handler import state

# Set a value
state.set("username", "bob")

# Get a value
print(state.get("username"))
```

---

## API Reference

### set(key, value)

Store a value in global state.

### get(key, default=None)

Retrieve a value.

### delete(key)

Remove a value.

### exists(key)

Returns `True` if key exists.

### all()

Returns a copy of all current state values.

---

## Persistence

```python
state.save("state.json")
state.load("state.json")
```

Saves and loads state from a file.

---

## Callbacks (Events)

Run code whenever state changes:

```python
def on_change(key, old, new):
    print(f"{key} changed from {old} to {new}")

state.register_callback(on_change)

state.set("mode", "debug")
state.set("mode", "release")
```

---

## Example

```python
import state_handler as sh

sh.state.set("mode", "debug")

if sh.state.get("mode") == "debug":
    print("Debug mode is ON")
```

---

## Why use this?

Sometimes you need shared state across multiple files without passing variables around. This package provides a simple global state system for Python projects.

---

## Roadmap

* Nested state support
* Async event listeners
* Thread-safe mode
* State syncing between processes

---

## License

MIT License
