-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(framework): support several runtimes simultaneously (#1691)
- Loading branch information
1 parent
095d6dc
commit 7a3261c
Showing
5 changed files
with
32 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,45 @@ | ||
const DefinitionsSet = new Set(); | ||
const Definitions = new Set(); | ||
const Failures = new Set(); | ||
let failureTimeout; | ||
|
||
const registerTag = tag => { | ||
DefinitionsSet.add(tag); | ||
Definitions.add(tag); | ||
}; | ||
|
||
const isTagRegistered = tag => { | ||
return DefinitionsSet.has(tag); | ||
return Definitions.has(tag); | ||
}; | ||
|
||
const getAllRegisteredTags = () => { | ||
const arr = []; | ||
DefinitionsSet.forEach(tag => { | ||
Definitions.forEach(tag => { | ||
arr.push(tag); | ||
}); | ||
return arr; | ||
}; | ||
|
||
const recordTagRegistrationFailure = tag => { | ||
Failures.add(tag); | ||
if (!failureTimeout) { | ||
failureTimeout = setTimeout(() => { | ||
displayFailedRegistrations(); | ||
failureTimeout = undefined; | ||
}, 1000); | ||
} | ||
}; | ||
|
||
const displayFailedRegistrations = () => { | ||
const tags = []; // IE only supports Set.prototype.forEach | ||
Failures.forEach(tag => { | ||
tags.push(tag); | ||
}); | ||
console.warn(`The following tags have already been defined by a different UI5 Web Components version: ${tags.join(", ")}`); // eslint-disable-line | ||
Failures.clear(); | ||
}; | ||
|
||
export { | ||
registerTag, | ||
isTagRegistered, | ||
getAllRegisteredTags, | ||
recordTagRegistrationFailure, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters