-
Notifications
You must be signed in to change notification settings - Fork 5
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
Refactor: Create parsed manifest type and centralize parsing in iiif-parser #226
Comments
Looking at clover they seem to recommend have a top-level fetch and then pass the values as props to "primitive" components (https://github.com/samvera-labs/clover-iiif/blob/main/pages/docs/composing.mdx#L166-L191). For non-primitives like Viewer they pass the manifest url and it fetches and parses the whole thing into a context (https://github.com/samvera-labs/clover-iiif/blob/main/src/components/Viewer/index.tsx#L44C1-L55). Curiously that uses a @iiif/vault which is itself a store which fetches, parses, and normalizes presentation manifests (https://github.com/IIIF-Commons/vault/blob/main/docs/getting-started.md). It currently uses redux but is looking at using zustand(https://github.com/pmndrs/zustand) in version 1 (whenever that happens). These provide a lot of examples that could be useful for better forming a path forward with respect to state management. |
Another refactor idea: Use React refs in place of state hooks to avoid the number of rerenders. For example structure navigation clicks cause a rerender of that component. |
Another way to manage state optimizing the use of the virtual DOM minimizing re-renders in the whole component tree: https://preactjs.com/blog/introducing-signals/ |
Could be broken into 2 main issues: UI update, and components parsing their own information
|
Explore the option of using |
We'll want to update state management; explore options for state updates and possibly restructure how the data is arranged between reading the manifest and having different components parse at different times. After this, we could clean up further code in the companion ticket #593. |
Current Code Structure
Components listen for when the unparsed manifest is set in the state. When that happens they call
parseManifest
and pass it to methods iniiif-parser
and set the result in the state. They focus on just the information they need for themselves.Proposal
Create a type for the parsed manifest with fields ramp needs.
iiif-parser
will have a single point of entry for parsing which will return an object of the new type to be stored in the state as one large object. The manifest state can then spread the object and update individual values as individual components need to update the state based upon user interactions.Goals (break into 2 issues)
Pros
parseManifest
one timeCons
Investigation/Done Looks Like
Prior Work
Proof of concept PR: #222
The text was updated successfully, but these errors were encountered: