Skip to content

fix: update ensemble storage #1061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

fix: update ensemble storage #1061

wants to merge 2 commits into from

Conversation

sagardspeed2
Copy link
Contributor

@sagardspeed2 sagardspeed2 commented Mar 25, 2025

Describe your changes

update ensemble storage to share the values on multiple screens

Screenshots [Optional]

Before:

Screen.Recording.2025-03-25.at.7.02.02.PM.mp4

After:

Screen.Recording.2025-03-25.at.6.53.44.PM.mp4

Issue ticket number and link

Closes #

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have added tests
  • I have added a changeset pnpm changeset add
  • I have added example usage in the kitchen sink app

@sagardspeed2 sagardspeed2 requested a review from evshi March 25, 2025 13:19
@sagardspeed2 sagardspeed2 self-assigned this Mar 25, 2025
Copy link

changeset-bot bot commented Mar 25, 2025

⚠️ No Changeset found

Latest commit: 81bdc35

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented Mar 25, 2025

Visit the preview URL for this PR (updated for commit 81bdc35):

https://react-kitchen-sink-dev--pr1061-update-storage-465y6khg.web.app

(expires Tue, 01 Apr 2025 13:23:53 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 6267897ade2ba783b6db70a53a60fc3946d625e9

Copy link
Contributor

@evshi evshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what the issue is? This change will add a lot of extra renders.

Comment on lines +56 to 63
const storage = useEnsembleStorage();

return useAtomCallback(
useCallback(
(get, set, ...args: T) => {
const applicationContext = get(appAtom);
const screenContext = get(screenAtom);
const storage = get(screenStorageAtom);
const device = get(deviceAtom);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not right - the reason we use get instead of the hook here is to prevent unnecessary re-renders whenever the storage is changed.

() => createStorageApi(storageBuffer, setStorage),
[setStorage, storageBuffer],
);
const storageApi = createStorageApi(storage, setStorage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

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.

2 participants