Skip to content

feat: Native implementation for listeners (also now fires for AppClip/extension changes)#1067

Open
mrousavy wants to merge 1 commit into
mainfrom
codex/add-native-mmkv-handler-listeners
Open

feat: Native implementation for listeners (also now fires for AppClip/extension changes)#1067
mrousavy wants to merge 1 commit into
mainfrom
codex/add-native-mmkv-handler-listeners

Conversation

@mrousavy
Copy link
Copy Markdown
Owner

@mrousavy mrousavy commented Jun 3, 2026

Summary

  • Register a singleton native MMKVHandler during MMKV initialization and forward MMKV logs through Nitro's logger.
  • Replace the value-only native registry with a per-MMKV-ID listener registry that routes both local key-level changes and native outer-process content changes through the existing addOnValueChangedListener(...) API.
  • Add checkExternalContentChanged() to the MMKV HybridObject, with web/mock no-ops.
  • Conservatively fan out external content changes to all current and previously known keys, since upstream MMKV only reports the mmap ID and not the changed key.
  • Refresh external changes on app foreground by calling checkExternalContentChanged() from the existing AppState listener setup.
  • Add docs and Harness coverage for the new check API.

Verification

  • bun run specs
  • bun run lint-cpp
  • bun lint-ci
  • bun run typecheck
  • bun run test -- packages/react-native-mmkv/src/__tests__/hooks.test.tsx --runInBand
  • HARNESS_WEB_URL=http://localhost:3000 bun --cwd example test:harness __tests__/MMKV.harness.ts --harnessRunner web
  • cd example/android && ./gradlew :react-native-mmkv:externalNativeBuildRelease --no-daemon

Note: earlier local bun --cwd example build:android-release passed the react-native-mmkv native C++ build for all ABIs, then failed later in :app:createBundleReleaseJsAndAssets while starting the local node_modules/react-native/sdks/hermesc/osx-bin/hermesc binary. The previous CI run passed Android build, iOS build, Android Harness, Web Harness, and all fast checks before this API simplification; CI is rerunning for the amended head.

@mrousavy mrousavy force-pushed the codex/add-native-mmkv-handler-listeners branch from bcd8292 to 9aa33c4 Compare June 3, 2026 14:10
@mrousavy mrousavy changed the title feat: bridge external MMKV content changes feat: Native implementation for listeners (also now fires for AppClip/extension changes) Jun 3, 2026
@mrousavy mrousavy force-pushed the codex/add-native-mmkv-handler-listeners branch from 9aa33c4 to 46e1adf Compare June 3, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant