Reactive ⚡️
Framework inspirado en React para crear aplicaciones CLI dinámicas con Prompt Toolkit (Python). Crea interfaces terminal con componentes, estado reactivo y hooks.
Características principales ✨
- 🧩 Arquitectura basada en componentes con enfoque funcional
- ⚛️ Hooks API familiar (
use_state,use_effect,use_ref) - 🔄 Actualizaciones de estado eficientes con re-renderizado automático
- ⌨️ Manejo integrado de eventos y key bindings
- 🧪 Testing fácil gracias a componentes desacoplados
Instalación 💻
pip install reactive-toolkit
Ejemplo 🧪
from reactive import component, Button, use_state
from prompt_toolkit.widgets import Label
@component
def CounterApp():
count, set_count = use_state(0)
def increment():
set_count(count + 1)
def decrement():
set_count(count - 1)
return [
f'Contador: {count}',
Button(text='➕ Incrementar', handler=increment),
Button(text='➖ Decrementar', handler=decrement)
]
# Ejecutar la aplicación
if __name__ == "__main__":
from reactive import create_root, run_app
root, key_bindings = create_root(CounterApp)
run_app(root, key_bindings=key_bindings)
Flujo de trabajo básico 🔄
graph TD
A[Estado Cambia] --> B[Re-render Componente]
B --> C[Actualizar UI]
C --> D[Esperar Interacción]
D --> A
Hooks disponibles 🪝
Hooks esenciales
| Hook | Descripción |
|---|---|
use_state() |
Gestión básica de estado |
use_effect() |
Manejo de efectos secundarios |
use_ref() |
Referencias a elementos |
use_context() |
Acceso al contexto global |
use_provider() |
Consume datos de proveedores de contexto |
Hooks avanzados
| Hook | Descripción |
|---|---|
use_id() |
Genera IDs únicos para accesibilidad |
use_key() |
Manejo personalizado de eventos de teclado |
use_memo() |
Memoización de valores costosos |
use_navigation() |
Acceso a rutas y navegación |
Hooks personalizados
¡Crea tus propios hooks para reutilizar lógica! Ejemplo:
from reactive import hook, component, Button
@hook
def use_toggle(initial: bool = False):
state, set_state = use_state(initial)
toggle = lambda: set_state(not state)
return state, toggle
# Uso en componente:
@component
def Switch():
is_on, toggle = use_toggle()
return Button(
text = 'on' if is_on else 'off',
handler = toggle
)
Contribuir 🤝
¡PRs son bienvenidos! Para contribuir:
- Haz fork del repositorio
- Crea una rama con tu feature (git checkout -b feature/nueva-funcionalidad)
- Haz commit de tus cambios (git commit -am 'Agrega nueva funcionalidad')
- Haz push a la rama (git push origin feature/nueva-funcionalidad)
- Abre un Pull Request
Metadata
Release files for reactive-toolkit 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| reactive_toolkit-1.0.0.tar.gz | 43.5 kB | Without provenance | Details for reactive_toolkit-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| reactive_toolkit-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for reactive_toolkit-1.0.0-py3-none-any.whl |
Total release size: 101.9 kB
Release files / reactive_toolkit-1.0.0.tar.gz
| Download URL | reactive_toolkit-1.0.0.tar.gz |
|---|---|
| Size | 43.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a557d4f50eee1f0a7767488879c6284bf4a4a8c5535e8b4af45cf8e9b4aad5d
|
|
BLAKE2b-256 checksum How to use checksums |
d4c856dd1fbfbe9b1d022d79cff91ab9a833aa70e9f31300994101dde4e01d65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.20
|
Release files / reactive_toolkit-1.0.0-py3-none-any.whl
| Download URL | reactive_toolkit-1.0.0-py3-none-any.whl |
|---|---|
| Size | 58.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c54117e71510d4d12277eb2f2e2866f586db92f6556301ecddd22bfdd6e9377
|
|
BLAKE2b-256 checksum How to use checksums |
456e4c52fa327b16a6a0b2baaaa05cad10856842ffca95cc5fc910375c1ef198
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.20
|
Security for reactive-toolkit 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.