diff --git a/README.md b/README.md index 208245a..01d5f22 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,37 @@ You can lazy load any component providing a fallback component during the loadin ``` +When the component is loaded, Lazy will dispatch a 'load' event from the component root element. + +This can be useful e.g. for removing splashscreen on app start: + +```riot + + + + + +``` + Lazy loading Riot.js components is recommended combined with [`@riotjs/route`](https://github.com/riot/route) ```riot diff --git a/index.next.js b/index.next.js index 36b97ea..8402f78 100644 --- a/index.next.js +++ b/index.next.js @@ -20,7 +20,7 @@ lazy.export = function lazyExport(Loader, Component) { this.isMounted = true const mount = () => { this.mountLazyComponent(parentScope) - this.el.dispatchEvent(new Event("load")) + this.el.dispatchEvent(new Event('load')) } if (cachedComponent) { diff --git a/test/components/component-with-load-listener.riot b/test/components/component-with-load-listener.riot new file mode 100644 index 0000000..de09493 --- /dev/null +++ b/test/components/component-with-load-listener.riot @@ -0,0 +1,18 @@ + + + + + \ No newline at end of file diff --git a/test/components/user-wrapper-without-loader.riot b/test/components/user-wrapper-without-loader.riot index a079ea7..99274f2 100644 --- a/test/components/user-wrapper-without-loader.riot +++ b/test/components/user-wrapper-without-loader.riot @@ -2,7 +2,6 @@