useSubscribeToResource
A hook that lets you subscribe to a list of Resource URLs via WebSockets.
When a resource is updated on a Pod, the updates will automatically be reflected in LDO.
import { useSubscribeToResource, useSubject } from "@ldo/solid-react";
import React, { FunctionComponent } from "react";
import { ProfileShapeType } from "./.ldo/Profile.shapeType";
const Component: FunctionComponent = () => {
// Subscribes to updates on the Pod for the given resources. If the Pod is
// updated, any component touching changed data will rerender.
useSubscribeToResource(
"https://example.com/Person1",
"https://example.com/Person2"
);
const profile1 = useSubject(
ProfileShapeType,
"https://example.com/Person1#me"
);
const profile2 = useSubject(
ProfileShapeType,
"https://example.com/Person2#me"
);
return (
<div>
<p>Profile1: {profile1?.name}</p>
<p>Profile2: {profile2?.name}</p>
</div>
);
};
Parameters
...resourceUris: string[]
- A list of resource URIs to subscribe to.
Returns
Void.