First create the NX workspace and the initial application named search
:
npx create-nx-workspace@latest ang-pokemon-mfe
Set it up as angular, with the name search
and SCSS for the styling:
[ | |
{ "name": "Atreides", "planets": "Calladan" }, | |
{ "name": "Corrino", "planets": ["Kaitan", "Salusa Secundus"] }, | |
{ "name": "Harkonnen", "planets": ["Giedi Prime", "Arrakis"] } | |
] |
class EventProcessor { | |
handleEvent(eventName: ..., data: ...): void { | |
} | |
addHandler(handler: ...) { | |
} | |
getProcessedEvents(): ...[] { | |
} | |
} |
const delay = <T>(time: number, data: T): Promise<T> => | |
new Promise((resolve) => | |
setTimeout(() => { | |
resolve(data); | |
}, time) | |
); | |
class Users { | |
async getUsers() { | |
return await delay(1000, []); |
First create the NX workspace and the initial application named search
:
npx create-nx-workspace@latest ang-pokemon-mfe
Set it up as angular, with the name search
and SCSS for the styling:
{ | |
"name": "packages", | |
"version": "1.0.0", | |
"main": "index.js", | |
"license": "MIT", | |
"private": true, | |
"scripts": { | |
"start": "concurrently \"wsrun --parallel start\"" | |
}, | |
"workspaces": [ |
const numberFormat = new Intl.NumberFormat("en-US", { style: "decimal" }); | |
const TEST_ARRAY_SIZE = 1000; | |
const TEST_COUNT = 1000; | |
const pushUsingPush = (arr) => { | |
arr.push(5); | |
return arr; | |
}; |
Frameworks like React require that when you change the contents of an array or object you change its reference. Or push another way that you don't change arrays but instead create new arrays with updated values (i.e. immutability).
There are older array methods that are incompatible with immutability because they alter the array in place and don't change the array reference. These are mutable (or destructive) methods.
Shown below are replacements for the array destructive methods (e.g. push
, pop
, splice
, sort
, etc.) that will create new array references with the updated data.
Solutions are provided using the spread operator and also the newer "change array by copy" methods (toSpliced
, toSorted
, toReversed
and with
).
/* | |
There is currently no way to get a `.astro` route to just return the HTML | |
without the CSS and JS. This is a workaround to remove the CSS and JS from | |
the HTML response of HTMX fragment routes. | |
The premise here is that HTMX fragments won't required additional styles because | |
the Tailwind for the entire experience is alreay precomputed. And second that it will | |
not require additional JS because ... HTMX. | |
*/ | |
const HTMX_FRAGMENT_ROUTES = ["/prompt"]; |
export function runify(obj) { | |
if(Array.isArray(obj)) { | |
return obj.map(runify); | |
} else if(typeof obj === 'object') { | |
let rune = $state(obj); | |
let output = {}; | |
for(let key in rune) { | |
if(typeof obj[key] === 'object') { | |
obj[key] = runify(obj[key]); | |
} |