Skip to content

Commit

Permalink
Update NativeMmkv.ts
Browse files Browse the repository at this point in the history
rename to mmkvModule
  • Loading branch information
arasrezaei authored Sep 9, 2024
1 parent ccaf839 commit aa71e92
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions package/src/NativeMmkv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,23 @@ export interface Spec extends TurboModule {
createMMKV(configuration: Configuration): UnsafeObject;
}

let Module: Spec | null;
let mmkvModule: Spec | null;

export function getMMKVTurboModule(): Spec {
try {
if (Module == null) {
if (mmkvModule == null) {
// 1. Load MMKV TurboModule
Module = TurboModuleRegistry.getEnforcing<Spec>('MmkvCxx');
mmkvModule = TurboModuleRegistry.getEnforcing<Spec>('MmkvCxx');

// 2. Get the PlatformContext TurboModule as well
const platformContext = getMMKVPlatformContextTurboModule();

// 3. Initialize it with the documents directory from platform-specific context
const basePath = platformContext.getBaseDirectory();
Module.initialize(basePath);
mmkvModule.initialize(basePath);
}

return Module;
return mmkvModule;
} catch (cause) {
// TurboModule could not be found!
throw new ModuleNotFoundError(cause);
Expand Down

0 comments on commit aa71e92

Please sign in to comment.