0.1.1 • Published 11 months ago
@pemako.io/pemako-client v0.1.1
Pemako Client Code Organization
This directory contains the code for the Pemako Client.
Directory Structure
context/: Contains React context providersPemakoContext.tsx: Core context provider for the application
hooks/: Custom React hooksusePemakoContext.ts: Hook for accessing the Pemako contextusePemakoSession.ts: Hook for interacting with a specific Pemako session
services/: Business logic separated into serviceswebsocket/: WebSocket-related functionalityWebSocketService.ts: Handles WebSocket connection and message processing
gompa/: Gompa component managementGompaService.ts: Manages gompa registration, state, and actions
message/: Message handlingMessageService.ts: Handles sending and receiving messages
types/: TypeScript type definitions (imported by all modules)
Architecture Overview
The application follows a service-oriented architecture where:
- The
PemakoContextprovides application-wide state and methods - Services handle specific domain logic and are imported by the context
- Hooks provide React components with access to context functionality
Usage
Import the hooks for use in components:
import { usePemakoContext, usePemakoSession } from './pemako-client';
// Use the global context
const { createSession } = usePemakoContext();
// Or work with a specific session
const { sendMessage, messages, isLoading } = usePemakoSession(sessionId);