Skip to content

Commit

Permalink
fix: assigning modules to window.CoCreate
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Dec 16, 2023
1 parent 5e489e6 commit 15037d8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import observer from '@cocreate/observer';

function listen(name, callback, selector) {

function observerCallback({ target }) {
// let isInit = target.querySelector(selector)/testtt
// if (isInit) {
callback()
// console.log('lazyloaded', selector)
async function observerCallback({ target }) {
const module = await callback()
observer.uninit(observerCallback)
Object.assign(window.CoCreate, {
[name]: module.default || module
});

dispatchComponentLoaded(name)
// }
}

observer.init({
Expand Down Expand Up @@ -57,7 +57,7 @@ export async function lazyLoad(name, selector, callback) {
export async function dependency(name, promise) {
let component = await promise;
Object.assign(window.CoCreate, {
[name]: component.default
[name]: component.default || component
});
dispatchComponentLoaded(name)
}
Expand Down

0 comments on commit 15037d8

Please sign in to comment.