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

Vue 'useSubjects' hook doesn't always use all the data. #534

Open
saul-jb opened this issue Dec 5, 2024 · 1 comment
Open

Vue 'useSubjects' hook doesn't always use all the data. #534

saul-jb opened this issue Dec 5, 2024 · 1 comment

Comments

@saul-jb
Copy link
Contributor

saul-jb commented Dec 5, 2024

The 'useSubjects' hook in vue seems to return different data depending on when it is called. This in practice seems to make it rather consistently work on a different subset of the data.

I have made a repo to reproduce this issue that uses the same component twice, the first one is as is and the second one is on a 1s delay leading to this result:

image

I have only added numbers in the first component and letters in the second but they are both using the same component, subject class, perspective & channel. They consistently load the data like that after a page reload.

From what I have figured out so far is that this line returns the different subset:

res = await this.perspective.infer(
`subject_class("${this.className}", C), instance(C, Base), triple("${tempSource}", Predicate, Base).`
);

@saul-jb
Copy link
Contributor Author

saul-jb commented Dec 6, 2024

It looks like since the perspective & source values are not reactive when passed to the useSubjects hook meaning if the perspective isn't loaded yet it attaches to the source 'ad4m://self' instead of the perspective which leads to the 2 sets of data.

I can get around it for now by passing in computed properties which ensures the hook can pickup on the changes:

const { entries: todos, repo } = useSubjects({
  perspective: computed(() => perspective),
  source: computed(() => source),
  subject: Todo,
});

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

No branches or pull requests

1 participant