@viewfly/router 0.0.17 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -319,12 +319,13 @@ function RouterOutlet(props) {
319
319
  return;
320
320
  }
321
321
  const { routeConfig, remainingPath } = result;
322
- const matchingRouteComponent = routeConfig.component;
323
- if (matchingRouteComponent instanceof Promise) {
324
- matchingRouteComponent.then(result => _updateChildren(result, remainingPath));
322
+ if (routeConfig.component) {
323
+ _updateChildren(routeConfig.component, remainingPath);
325
324
  }
326
- else {
327
- _updateChildren(matchingRouteComponent, remainingPath);
325
+ else if (routeConfig.asyncComponent) {
326
+ routeConfig.asyncComponent().then(c => {
327
+ _updateChildren(c, remainingPath);
328
+ });
328
329
  }
329
330
  }
330
331
  function _updateChildren(Component, remainingPath) {
package/bundles/index.js CHANGED
@@ -321,12 +321,13 @@ function RouterOutlet(props) {
321
321
  return;
322
322
  }
323
323
  const { routeConfig, remainingPath } = result;
324
- const matchingRouteComponent = routeConfig.component;
325
- if (matchingRouteComponent instanceof Promise) {
326
- matchingRouteComponent.then(result => _updateChildren(result, remainingPath));
324
+ if (routeConfig.component) {
325
+ _updateChildren(routeConfig.component, remainingPath);
327
326
  }
328
- else {
329
- _updateChildren(matchingRouteComponent, remainingPath);
327
+ else if (routeConfig.asyncComponent) {
328
+ routeConfig.asyncComponent().then(c => {
329
+ _updateChildren(c, remainingPath);
330
+ });
330
331
  }
331
332
  }
332
333
  function _updateChildren(Component, remainingPath) {
@@ -3,7 +3,8 @@ import { Observable } from '@tanbo/stream';
3
3
  import { Navigator, QueryParams } from './navigator';
4
4
  export interface RouteConfig {
5
5
  name: string;
6
- component: JSXInternal.ElementClass | Promise<JSXInternal.ElementClass>;
6
+ component?: JSXInternal.ElementClass;
7
+ asyncComponent?: () => Promise<JSXInternal.ElementClass>;
7
8
  beforeEach?(): boolean | Promise<boolean>;
8
9
  }
9
10
  export declare class Router {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewfly/router",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "A routing library based on the Viewfly framework that can be run in the browser or Nodejs background.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -13,7 +13,7 @@
13
13
  "keywords": [],
14
14
  "dependencies": {
15
15
  "@tanbo/stream": "^1.2.0",
16
- "@viewfly/core": "^0.0.17",
16
+ "@viewfly/core": "^0.0.18",
17
17
  "url": "^0.11.1"
18
18
  },
19
19
  "devDependencies": {
@@ -34,5 +34,5 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/viewfly/viewfly.git/issues"
36
36
  },
37
- "gitHead": "7a61edbca87f411d2ddbb390eb0b2e0416d80551"
37
+ "gitHead": "1cc6ec2decf3173792086553af0b3e171d49deae"
38
38
  }