Skip to content

feat: room-store: expose bound useRoomStore API, add useRoomStoreApi - #360

Merged
ilyabo merged 1 commit into
mainfrom
feat--room-store--expose-bound-useRoomStore-API-and-add-useRoomStoreApi-hook
Feb 13, 2026
Merged

ilyabo merged 1 commit into
mainfrom
feat--room-store--expose-bound-useRoomStore-API-and-add-useRoomStoreApi-hook

Conversation

@ilyabo

@ilyabo ilyabo commented Feb 11, 2026 •

Copy link
Copy Markdown
Collaborator

fixes #335

Makes imperative room-store access reliable by aligning useRoomStore with Zustand-style bound store methods (getState, setState, subscribe, getInitialState) while preserving selector-based usage. Adds useRoomStoreApi() for context-based imperative access, re-exports it from room-store and room-shell, and updates docs (whats-new + room-store README) including non-reactive usage guidance.

Summary by CodeRabbit

  • New Features

    • Added useRoomStoreApi() hook for context-based imperative access to room store.
    • Exposed Zustand methods (getState, setState, subscribe, getInitialState) through room store hooks alongside selector support.
  • Documentation

    • Updated release notes documenting new imperative access capabilities.
    • Enhanced README with code examples demonstrating module-level and context-based imperative patterns.

@coderabbitai

coderabbitai Bot commented Feb 11, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Version 0.27.0-rc.5 introduces imperative Zustand store access through augmented useRoomStore hooks with built-in API methods (getState, setState, subscribe, getInitialState) and new useRoomStoreApi() for context-based non-reactive access. Public exports are reorganized across packages.

Changes

Cohort / File(s) Summary
Documentation
docs/whats-new.md, packages/room-store/README.md
Updated version header and release notes with new useRoomStoreApi() feature announcement; added "Imperative Access" section with code examples and prop name clarification (roomStore prop).
Room Store Core Implementation
packages/room-store/src/BaseRoomStore.ts, packages/room-store/src/RoomStateProvider.tsx, packages/room-store/src/index.ts
Introduced RoomStoreApiMethods and UseRoomStore types; created withRoomStoreApi wrapper and getStoreOrThrow helper to expose Zustand methods on hooks; added useRoomStoreApi() non-reactive context hook; updated exports and hook signatures.
Room Shell Public API
packages/room-shell/src/index.ts
Reorganized re-exports from room-store and room-config; added useShallow, createPersistHelpers, createSlice, useRoomStoreApi to public surface; replaced RoomStateProviderProps with BaseRoomStore and UseRoomStore types; expanded data source and layout type exports.

Sequence Diagram

sequenceDiagram
    participant Component
    participant RoomStateProvider as RoomStateProvider<br/>(RoomStateContext)
    participant Store as Zustand Store<br/>(StoreApi)

    rect rgba(76, 175, 80, 0.5)
    Note over Component,Store: Reactive Access Pattern
    Component->>Component: useRoomStore(selector)
    Component->>Store: subscribe & get selected state
    Store->>Component: return selected value T
    end

    rect rgba(33, 150, 243, 0.5)
    Note over Component,Store: Imperative Access Pattern
    Component->>Component: useRoomStoreApi()
    Component->>RoomStateProvider: retrieve StoreApi from context
    RoomStateProvider->>Store: return raw StoreApi
    Store->>Component: {getState, setState, subscribe, getInitialState}
    Component->>Store: call getState/setState/subscribe as needed
    Store->>Component: perform imperative operation
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 With whiskers twitching at this store,
Imperative hooks are here to explore,
getState and setState now within reach,
Through context providers, lessons we teach,
Reactive and imperative, both paths unite,
Our room stores shine ever so bright! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: exposing bound useRoomStore API methods and adding the useRoomStoreApi hook, which are the primary features introduced across multiple files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat--room-store--expose-bound-useRoomStore-API-and-add-useRoomStoreApi-hook

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ilyabo ilyabo changed the title feat: room-store: expose bound useRoomStore API and add useRoomStoreA… feat: room-store: expose bound useRoomStore API, add useRoomStoreApi Feb 11, 2026
@ilyabo
ilyabo merged commit c5b68a3 into main Feb 13, 2026
7 checks passed
@ilyabo
ilyabo deleted the feat--room-store--expose-bound-useRoomStore-API-and-add-useRoomStoreApi-hook branch February 13, 2026 16:52
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.

⁨useRoomStore⁩ doesn't reliably expose ⁨getState()

1 participant