-
Notifications
You must be signed in to change notification settings - Fork 15
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 multi-doc example #43
Comments
cc @NSeydoux |
See also further comments in that gitter conversation from @RubenVerborgh; in general, an app should not know where data lives. So the app would just retrieve each friend's name from "the web". But having said that, currently in practice the app often does (need to) know, and so if an app wants to retrieve each friend's name from that friend's profile, the code would be something like: const friends = [];
for await (const friend of person.friends) {
const name = await data[friend].name;
friends.push(name.value);
} |
Note that a (slightly more cryptic?) alternative to friends.push(name.value); there would be friends.push(`${name}`); which I think is why you don't see the |
Exactly; the |
@RubenVerborgh a coding pattern we've fallen into using is something along the lines of
So basically in a function (or UI binding object, or React state object, wherever we need to use the value) we check to see if the proxy exists then return the value or an appropriate default value. There may be a better way to handle this, but it works nicely for our purposes, and it might be good to have some extra examples including how to handle null/empty values. We ran into issues early on since if the predicate or subject doesn't exist, the proxy is null, so the .value blows up. |
@james-martin-jd Hmm, we probably want something like |
Yes I think that sounds right - if the proxy itself is undefined it throws errors that the root object is undefined, not the .value. But really, I want to know about the value, not the proxy itself. |
The example in https://github.com/solid/query-ldflex/blob/master/demo/profile.js works inside one document. But if a profile only contains the
foaf:knows
triple, then the objects of those will need to be dereferenced before you can produce a list of first names of someone's friends. With @Vinnl, @james-martin-jd and myself we eventually worked out how to do that, in this chat conversation: https://gitter.im/solid/app-development?at=5d9de406b385bf2cc69f6c8dWould be good to add an example of that (or maybe even better, a link to a tutorial) to the readme of this repo!
The text was updated successfully, but these errors were encountered: