@goji/core
Advanced tools
Comparing version 0.6.8 to 0.6.9
@@ -16,8 +16,12 @@ "use strict"; | ||
const subtreeId = instance.getSubtreeId(); | ||
// If `attached` run before `getPublicInstance` we can get the component instance in sync | ||
let componentInstance = Promise.resolve(subtreeId !== undefined && publicInstance_1.subtreeInstances.has(subtreeId) | ||
? publicInstance_1.subtreeInstances.get(subtreeId) | ||
: undefined); | ||
// if `attached` have not run, we should wait for attach been called | ||
if (!componentInstance && subtreeId !== undefined) { | ||
let componentInstance; | ||
if (subtreeId === undefined) { | ||
componentInstance = undefined; | ||
} | ||
else if (publicInstance_1.subtreeInstances.has(subtreeId)) { | ||
// If `attached` run before `getPublicInstance` we can get the component instance in sync | ||
componentInstance = publicInstance_1.subtreeInstances.get(subtreeId); | ||
} | ||
else { | ||
// if `attached` have not run, we should wait for attach been called | ||
componentInstance = new Promise(resolve => { | ||
@@ -30,3 +34,3 @@ subtreeAttachEvents_1.default.on(String(subtreeId), () => resolve(publicInstance_1.subtreeInstances.get(subtreeId))); | ||
unsafe_gojiId: instance.id, | ||
getComponentInstance: () => componentInstance, | ||
getComponentInstance: () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return componentInstance; }), | ||
}; | ||
@@ -33,0 +37,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { __awaiter } from "tslib"; | ||
import { ElementInstance, TextInstance } from './instance'; | ||
@@ -12,8 +13,12 @@ import { subtreeInstances } from './publicInstance'; | ||
const subtreeId = instance.getSubtreeId(); | ||
// If `attached` run before `getPublicInstance` we can get the component instance in sync | ||
let componentInstance = Promise.resolve(subtreeId !== undefined && subtreeInstances.has(subtreeId) | ||
? subtreeInstances.get(subtreeId) | ||
: undefined); | ||
// if `attached` have not run, we should wait for attach been called | ||
if (!componentInstance && subtreeId !== undefined) { | ||
let componentInstance; | ||
if (subtreeId === undefined) { | ||
componentInstance = undefined; | ||
} | ||
else if (subtreeInstances.has(subtreeId)) { | ||
// If `attached` run before `getPublicInstance` we can get the component instance in sync | ||
componentInstance = subtreeInstances.get(subtreeId); | ||
} | ||
else { | ||
// if `attached` have not run, we should wait for attach been called | ||
componentInstance = new Promise(resolve => { | ||
@@ -26,3 +31,3 @@ events.on(String(subtreeId), () => resolve(subtreeInstances.get(subtreeId))); | ||
unsafe_gojiId: instance.id, | ||
getComponentInstance: () => componentInstance, | ||
getComponentInstance: () => __awaiter(void 0, void 0, void 0, function* () { return componentInstance; }), | ||
}; | ||
@@ -29,0 +34,0 @@ } |
{ | ||
"name": "@goji/core", | ||
"version": "0.6.8", | ||
"version": "0.6.9", | ||
"description": "GojiJS Core", | ||
@@ -94,3 +94,3 @@ "main": "dist/cjs/index.js", | ||
}, | ||
"gitHead": "235eaabb89e8a430487dcc29683eb16bf2ef3230" | ||
"gitHead": "ea5d2bfbdcfc390ae4c85a91b9ce1dcba7412cb7" | ||
} |
@@ -31,11 +31,11 @@ import { Container } from '../container'; | ||
// If `attached` run before `getPublicInstance` we can get the component instance in sync | ||
let componentInstance = Promise.resolve( | ||
subtreeId !== undefined && subtreeInstances.has(subtreeId) | ||
? subtreeInstances.get(subtreeId) | ||
: undefined, | ||
); | ||
// if `attached` have not run, we should wait for attach been called | ||
if (!componentInstance && subtreeId !== undefined) { | ||
let componentInstance; | ||
if (subtreeId === undefined) { | ||
componentInstance = undefined; | ||
} else if (subtreeInstances.has(subtreeId)) { | ||
// If `attached` run before `getPublicInstance` we can get the component instance in sync | ||
componentInstance = subtreeInstances.get(subtreeId); | ||
} else { | ||
// if `attached` have not run, we should wait for attach been called | ||
componentInstance = new Promise(resolve => { | ||
@@ -49,3 +49,3 @@ events.on(String(subtreeId), () => resolve(subtreeInstances.get(subtreeId))); | ||
unsafe_gojiId: instance.id, | ||
getComponentInstance: () => componentInstance, | ||
getComponentInstance: async () => componentInstance, | ||
}; | ||
@@ -52,0 +52,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1566818
12565