This file contains hidden or 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
| const form = document.querySelector("form"); | |
| form.addEventListener("submit", submitUserData); |
This file contains hidden or 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
| const getArguments = require('get-arguments-lib'); // Getting port & proxy hostname for arguments | |
| const read = require('read'); // Use to silence password | |
| const args = getArguments(process.argv); | |
| const port = args.port || 8080; | |
| const hostname = args.hostname | |
This file contains hidden or 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
| export const mapArrayItems = (data = []) => { | |
| if (!Array.isArray(data)) { | |
| return null; | |
| } | |
| return data.map((item) => { | |
| // some mapping | |
| }) | |
| } |
This file contains hidden or 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
| export const mapTreeNodes = (data = []) => data.map((item) => { | |
| // Do somethong | |
| }) |
This file contains hidden or 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
| async canGoOn(routeData, guard, oldGuard, prevUrl) { | |
| let result = true; | |
| if (oldGuard) { | |
| result = await oldGuard(prevUrl); | |
| } | |
| if (guard && result) { | |
| result = await guard(routeData) | |
| } |
This file contains hidden or 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
| { | |
| path: '/addImage', | |
| element: 'div', | |
| attributes: {is: 'add-image'}, | |
| deactivateGuard: confirmExit | |
| } |
This file contains hidden or 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
| const confirmExit = async () => { | |
| const confirmModal = document.createElement('confirm-modal'); | |
| confirmModal.comfirmQuestion = 'Are you sure?'; | |
| document.body.appendChild(confirmModal); | |
| const result = await confirmModal.getUserResult(); | |
| document.body.removeChild(confirmModal); | |
| return result; | |
| } |
This file contains hidden or 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
| async changeRoute(newRoute) { | |
| const treeBuilder = module.Router.router.routingSnapshotTreeBuilder | |
| const router = module.Router.router | |
| const newRouteData = treeBuilder.buildRouteTree(newRoute) | |
| if (!newRouteData) { | |
| throw Error(`Could not build tree for ${newRoute}`) | |
| } |
NewerOlder