Skip to content
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

add documentation on now to track useStore #6886

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

czuma
Copy link

@czuma czuma commented Sep 18, 2024

What is it?

  • Feature / enhancement
  • Bug
  • [ x ] Docs / tests / types / typos
  • Infra

Description

this add documentation on a case you want to track useStore and act when some of it's internal values change. This is added because the anonymous function expresed don't work and you need to provide the track function the object directly. more info here
https://discord.com/channels/842438759945601056/1161720833035743272

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have ran pnpm change and documented my changes
  • [ x ] I have made corresponding changes to the Qwik docs
  • Added new tests to cover the fix / functionality

this add documentation on a case you want to track useStore and act when some of it's internal values change. 
This is added because the anonymous function expresed don't work and you need to provide the track function the object directly.
more info here
https://discord.com/channels/842438759945601056/1161720833035743272
@czuma czuma requested a review from a team as a code owner September 18, 2024 02:33
Copy link

changeset-bot bot commented Sep 18, 2024

⚠️ No Changeset found

Latest commit: a6e7bff

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

@@ -232,6 +233,7 @@ const delay = (time: number) => new Promise((res) => setTimeout(res, time));

> Sometimes it is required to only run code either in the server or in the client. This can be achieved by using the `isServer` and `isBrowser` booleans exported from `@builder.io/qwik/build` as shown above.

> If you want to track `useStore()` objects and execute something when any of their internal values change, use `track(myExampleStore)` directly without the anonymous function. This prevents `track()` from losing the reference to the original reactive object.
Copy link
Member

Choose a reason for hiding this comment

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

This is inaccurate. What this non-function form does is tell track to treat it as a signal/store and subscribe to it. The function form would have to be track(() => Object.keys(store)).

In any case, it still doesn't subscribe to deep changes.

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