Skip to content

Instantly share code, notes, and snippets.

@amb26
Created May 8, 2025 15:21
Show Gist options
  • Select an option

  • Save amb26/2164b1cb78ddf069e1b5f1dcbd695dcb to your computer and use it in GitHub Desktop.

Select an option

Save amb26/2164b1cb78ddf069e1b5f1dcbd695dcb to your computer and use it in GitHub Desktop.
// Many thanks to Hugo Daniel https://hugodaniel.com/pages/boredom/ for inspiration for this concept
fluid.selfBootQuery = fluid.liveQuery("*[fl-layers]");
fluid.selfBootEffect = effect( () => {
const elements = fluid.selfBootQuery.value;
elements.forEach(element => {
const existing = fluid.viewContainerRegistry.get(element);
if (!existing) {
const layers = element.getAttribute("fl-layers");
const instance = fluid.viewComponent({
$layers: layers,
container: element
});
// Put this in early in case instantiation fails
fluid.viewContainerRegistry.set(element, instance);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment