@trap_stevo/tidesync v0.0.0
π TideSync β The Future of Real-Time State Management
Command the flow of real-time data like never before.
TideSync obliterates state inconsistencies, delivering instantaneous, fine-grained reactivity with WebSocket-driven precision. Built for speed, scalability, and dynamic event synchronization, it powers live dashboards, multiplayer experiences, chat systems, and beyond.
π Zero unnecessary re-renders
π State exists only when needed β no wasted memory
π Effortless state derivation β eliminate unnecessary useEffects
π Auto-reconnects with intelligent event recovery
π₯ TideSync doesnβt just manage state β it unleashes it.
π Features
β
Real-time, WebSocket-driven state updates β No polling, just instant synchronization.
β
Fine-grained subscriptions β Only affected components re-render.
β
Derived state support β Eliminates useEffect
overhead.
β
Lazy-loaded state β If itβs not used, it doesnβt exist.
β
Auto-reconnection & event persistence β Even unstable connections stay functional.
β
Blazing-fast event handling β Built for high-performance apps.
π Installation
npm install @trap_stevo/tidesync
π Usage
1οΈβ£ Wrap Your App with TideSyncProvider
import { TideSyncProvider } from "@trap_stevo/tidesync";
function App() {
return (
<TideSyncProvider tideURL="ws://localhost:8080">
<MainComponent />
</TideSyncProvider>
);
}
2οΈβ£ Instantly Sync State Across Components with useTideSyncState
import { useTideSyncState } from "@trap_stevo/tidesync";
const Counter = () => {
const [count, setCount] = useTideSyncState("count", 0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
};
π₯ State updates are broadcasted in real-time across all components!
3οΈβ£ Optimize Performance with useTideDerivedState
import { useTideSyncState, useTideDerivedState } from "@trap_stevo/tidesync";
const ComputedComponent = () => {
const [count] = useTideSyncState("count", 0);
const doubled = useTideDerivedState("doubled", () => count * 2);
return <p>Doubled Count: {doubled}</p>;
};
π₯ No re-renders, no extra computations β just pure speed.
4οΈβ£ Advanced Usage β Custom Event Names & Configuration
<TideSyncProvider
tideURL="ws://localhost:8080"
socketName="LiveSync"
eventNames={{
count: "update_count",
users: "sync_users"
}}
maxReconnectionAttempts={Infinity}
reconnectionAttempts={5}
maxReconnectDelay={10000}
>
<App />
</TideSyncProvider>
π₯ Tailor TideSync to your applicationβs needs.
π‘ Best Practices
- Use Derived State for Computations: Instead of using
useEffect
for calculations, preferuseTideDerivedState
. - Minimize Broadcasts: Only broadcast state updates when necessary by setting
broadcast = false
. - Use Event Mapping for Organized Data: Assign custom event names to keep your WebSocket events structured.
- Handle Reconnection Smartly: Set
maxReconnectionAttempts
appropriately to maintain a stable experience.
π Troubleshooting
State Not Updating Across Components?
Ensure youβre using useTideSyncState
within a TideSyncProvider
and the WebSocket connection is active.
Experiencing Delays in Updates?
Check your network stability and confirm that the eventNames
mapping aligns correctly with the WebSocket events.
WebSocket Keeps Disconnecting?
Increase maxReconnectionAttempts
or adjust maxReconnectDelay
in TideSyncProvider
.
π TideSync β The Ultimate Real-Time State Manager!
Eliminate state inconsistencies. Command real-time data like never before.
π Fast. π Scalable. π Unstoppable.
4 months ago