1.0.0 ⢠Published 6 months ago
@uistate/core v1.0.0
@uistate/core
High-performance UI state management using CSS custom properties. 44% faster than traditional state management solutions with 12.5% lower memory usage.
Features
- š 44% faster state updates than Redux
- š 12.5% lower memory usage
- šÆ Zero configuration
- š Automatic reactivity
- šØ Framework agnostic
- š¦ Tiny bundle size (~1KB)
- šŖ Full TypeScript support
- š Optional performance monitoring
Installation
# Install the core package
npm install @uistate/core
# Optional: Install performance monitoring
npm install @uistate/performance
Quick Start
import { UIState } from '@uistate/core';
// Initialize state
UIState.init();
// Set state
UIState.setState('count', 0);
// Get state
const count = UIState.getState('count');
// Subscribe to changes
const unsubscribe = UIState.observe('count', (newValue) => {
console.log('Count changed:', newValue);
});
// React Hook
import { useUIState } from '@uistate/core/react';
function Counter() {
const [count, setCount] = useUIState('count', 0);
return (
<button onClick={() => setCount(count + 1)}>
Count: {count}
</button>
);
}
Why @uistate/core?
Performance
- 44% Faster Updates: Leverages browser's CSS engine for optimal performance
- 12.5% Lower Memory: Efficient state storage using CSS custom properties
- Minimal Overhead: No virtual DOM diffing for state updates
Developer Experience
- Simple API: Just
setState
,getState
, andobserve
- TypeScript Support: Full type safety and autocompletion
- Framework Agnostic: Works with any framework
- Zero Config: No store setup, no reducers, no actions
Performance Monitoring
The @uistate/performance
package provides detailed performance metrics for your application:
import { PerformanceTracker } from '@uistate/performance';
import { PerformanceDisplay } from '@uistate/performance';
// Start tracking performance
const tracker = PerformanceTracker.getInstance();
tracker.start();
// Optional: Add the performance display component to your React app
function App() {
return (
<div>
<YourApp />
<PerformanceDisplay />
</div>
);
}
The performance tracker monitors:
- State update duration
- Component render time
- FPS (Frames Per Second)
- Memory usage
- Long task duration
Project Structure
@uistate/core/
āāā src/ # Core library
ā āāā index.ts # Main entry
ā āāā UIState.ts # Core implementation
ā āāā react/ # React bindings
ā āāā index.ts # React hooks
āāā packages/
ā āāā performance/ # Performance monitoring package
āāā examples/ # Example applications
āāā traditional/ # Traditional Redux app
āāā uistate/ # UIState implementation
Browser Support
- Chrome 60+
- Firefox 54+
- Safari 10.1+
- Edge 79+
Contributing
We welcome contributions! Please see our Contributing Guide for details.
License
MIT Ā© Ajdin Imsirovic
1.0.0
6 months ago