-
What's the right way? <canvas-panel id="cp"></canvas-panel>
<script>
const vault = window.__hyperionVault__; // The global vault.
// am I using the same vault that cp is using?
</script> or <canvas-panel id="cp"></canvas-panel>
<script>
const vault = document.getElementById("cp").vault;
// .. do stuff with cp's vault that it made itself?
</script> or <canvas-panel id="cp"></canvas-panel>
<script>
const vault = new Vault();
cp.vault = vault;
// load stuff...
</script> And if so, can you do this? Would you ever do this? Is this nonsense? <canvas-panel id="cp1"></canvas-panel>
<canvas-panel id="cp2"></canvas-panel>
<script>
const vault1 = new Vault();
cp1.vault = vault1;
const vault2 = new Vault();
cp2.vault = vault2;
</script> |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
All very good questions. Hyperion has a global vault as a default that will end up covering 99% of use-cases. When creating a When using the web components though, it's unlikely that you would need to set the vault manually. The global is also available at:
Which would be preferred over: |
Beta Was this translation helpful? Give feedback.
-
This also needs similar consideration for frameworks. For example, in React, in your top level: <VaultContext>
<App />
</VaultContext> And then you can get access to the vault at any time, in any component using: const vault = useVault(); and then some React-specific abstractions. useVaultEffect(vault => {
doThisThing();
}, [whenThisChanges]) |
Beta Was this translation helpful? Give feedback.
All very good questions. Hyperion has a global vault as a default that will end up covering 99% of use-cases. When creating a
new Vault()
instance, you can override some of the internals - such as how IIIF is fetched. Madoc uses this to add authentication for example, and do some transformations after fetching.When using the web components though, it's unlikely that you would need to set the vault manually. The global is also available at:
Which would be preferred over:
window.__hyperionVault__