Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
refactor: export Lucia.component function for cleaner syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Nov 25, 2020
1 parent 694a3f2 commit 83c5187
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ import { computeProperties, safeEval } from './utils/compute';

export { App, createApp, h, compile, patch, observer, props, computeProperties };

export const component = (name: string, template: string) => {
return { name, template };
};

// Lucia.use function for user provided views in JavaScript
export const use = (
name: string,
view: Record<string, unknown>,
components: Record<string, string> = {}
...components: Record<string, string>[]
): App | void => {
const elements = Array.from(document.querySelectorAll(`[${DIRECTIVE_PREFIX}use]`));

Expand All @@ -25,7 +29,7 @@ export const use = (

if (componentScope === name) {
const app = createApp(view);
for (const [name, template] of Object.entries(components)) {
for (const { name, template } of components) {
app.component(name, template);
}
app.mount(el);
Expand Down

0 comments on commit 83c5187

Please sign in to comment.