1.3.4 User-Scoped Storage Pattern: Add StorageService integration across modules for improved data management
- Introduced STORAGE_SERVICE token in the DI container for consistent service registration. - Updated BaseService to include storageService as a dependency, ensuring proper initialization and error handling. - Refactored ChatService to utilize storageService for managing unread messages and peers, replacing localStorage usage. - Enhanced MarketStore to save and load orders using storageService, improving data persistence and user experience. - Registered storageService in the base module, ensuring it is initialized and disposed of correctly. This integration streamlines data handling across the application, promoting better maintainability and consistency.
This commit is contained in:
parent
3abdd2d7d9
commit
3cf10b1db4
6 changed files with 285 additions and 103 deletions
|
|
@ -12,6 +12,7 @@ import { pwaService } from './pwa/pwa-service'
|
|||
// Import core services
|
||||
import { paymentService } from '@/core/services/PaymentService'
|
||||
import { visibilityService } from '@/core/services/VisibilityService'
|
||||
import { storageService } from '@/core/services/StorageService'
|
||||
|
||||
/**
|
||||
* Base Module Plugin
|
||||
|
|
@ -36,6 +37,9 @@ export const baseModule: ModulePlugin = {
|
|||
// Register visibility service
|
||||
container.provide(SERVICE_TOKENS.VISIBILITY_SERVICE, visibilityService)
|
||||
|
||||
// Register storage service
|
||||
container.provide(SERVICE_TOKENS.STORAGE_SERVICE, storageService)
|
||||
|
||||
// Register PWA service
|
||||
container.provide('pwaService', pwaService)
|
||||
|
||||
|
|
@ -54,6 +58,10 @@ export const baseModule: ModulePlugin = {
|
|||
waitForDependencies: false, // VisibilityService has no dependencies
|
||||
maxRetries: 1
|
||||
})
|
||||
await storageService.initialize({
|
||||
waitForDependencies: true, // StorageService depends on AuthService
|
||||
maxRetries: 3
|
||||
})
|
||||
|
||||
console.log('✅ Base module installed successfully')
|
||||
},
|
||||
|
|
@ -66,6 +74,7 @@ export const baseModule: ModulePlugin = {
|
|||
await auth.dispose()
|
||||
await paymentService.dispose()
|
||||
await visibilityService.dispose()
|
||||
await storageService.dispose()
|
||||
|
||||
console.log('✅ Base module uninstalled')
|
||||
},
|
||||
|
|
@ -74,6 +83,8 @@ export const baseModule: ModulePlugin = {
|
|||
relayHub,
|
||||
auth,
|
||||
paymentService,
|
||||
visibilityService,
|
||||
storageService,
|
||||
pwaService
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue