β οΈ Js IntersectionObserver example
#js #IntersectionObserver
β Link: https://javascript.plainenglish.io/speed-up-your-javascript-proven-techniques-for-optimizing-performance-c3471f8df54f
#js #IntersectionObserver
β Link: https://javascript.plainenglish.io/speed-up-your-javascript-proven-techniques-for-optimizing-performance-c3471f8df54f
π1
js.reduce(): Group an array of objects by a specified property
#js #reduce
β Example:
#js #reduce
β Example:
function GroupBy(array, property) {
return array.reduce((acc, obj) => {
let key = obj[property];
acc[key] = acc[key] || [];
acc[key].push(obj);
return acc;
}, {});
}
const users = [
{ name: "Bytefer", age: 30 },
{ name: "Kakuqo", age: 28 },
{ name: "Chris", age: 28 },
];
const groupedUsers = GroupBy(users, "age");
// groupedUsers:
// {
// '28': [
// { name: 'Kakuqo', age: 28 },
// { name: 'Chris', age: 28 }
// ],
// '30': [
// { name: 'Bytefer', age: 30 }
// ]
// }π1
Custom
#rxjs #custom
β Link: https://medium.com/@amusedshadow/own-changedetection-rxjs-operator-alternative-of-async-pipe-b53ebb3daa4d
changeDetectOperator operator#rxjs #custom
β Link: https://medium.com/@amusedshadow/own-changedetection-rxjs-operator-alternative-of-async-pipe-b53ebb3daa4d
This media is not supported in your browser
VIEW IN TELEGRAM
CSS rare functions, properties, and features
#css
β Link: https://stackblitz.com/edit/js-w2yuvk?file=index.html
#css
β Link: https://stackblitz.com/edit/js-w2yuvk?file=index.html
β οΈ Using Observables as Outputs
#angular #directive #output #fromEvent
β Link: https://medium.com/ngconf/using-observables-as-outputs-de40aa167e09
#angular #directive #output #fromEvent
β Link: https://medium.com/ngconf/using-observables-as-outputs-de40aa167e09
βResponsive utilityβ Pipe: BreakpointObserver
#angular #cdk #pipe #BreakpointObserver
β Link: https://medium.com/@federico.monaldi/angular-write-a-responsive-utility-pipe-breakpointobserve-d9051c60cf9c
#angular #cdk #pipe #BreakpointObserver
β Link: https://medium.com/@federico.monaldi/angular-write-a-responsive-utility-pipe-breakpointobserve-d9051c60cf9c
js.reduce(): Serialize query parameter object
#js #reduce
β Example:
#js #reduce
β Example:
function StringifyQueryParam(queryParam = {}) {
return Object.entries(queryParam)
.reduce(
(t, v) =>
`${t}${v[0]}=${encodeURIComponent(v[1])}&`,
Object.keys(queryParam).length ? "?" : ""
)
.replace(/&$/, "");
}
const queryString = StringifyQueryParam({
name: "bytefer",
email: "bytefer@gmail.com",
});
// queryString: '?name=Bytefer&email=bytefer%40gmail.com'β οΈ Signals in Angular (new approach of reactivity)
#angular #signals
π© > Angular 16
β Link: https://medium.com/@simon.sharp_25406/signals-in-angular-3dc2c97ce5a6
#angular #signals
π© > Angular 16
β Link: https://medium.com/@simon.sharp_25406/signals-in-angular-3dc2c97ce5a6
js.reduce(): Deserialize query string
#js #reduce
β Example:
#js #reduce
β Example:
function ParseQueryString(queryString) {
return queryString
.replace(/(^\?)|(&$)/g, "")
.split("&")
.reduce((t, v) => {
const [key, val] = v.split("=");
t[key] = decodeURIComponent(val);
return t;
}, {});
}
const urlExample = "?name=Bytefer&email=bytefer%40gmail.com";
const queryParam = ParseQueryString(urlExample);
// queryParam: { name: 'Bytefer', email: 'bytefer@gmail.com' }β€2
js.reduce(): Split array into chunks
#js #reduce
β Example:
#js #reduce
β Example:
function Chunk(array, size) {
return array.reduce((acc, _, index) => {
if (index % size === 0) acc.push(array.slice(index, index + size));
return acc;
}, []);
}
const numbers = [1, 2, 3, 4, 5, 6, 7];
const arr3 = Chunk(numbers, 2);
// Output: arr3: [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7 ] ]Resolver in Angular
#angular #resolver
π© > Angular 15
β Link: https://stackblitz.com/edit/angular-2kiv4w?file=src%2Fapp%2Fhero-detail%2Fhero-detail.resolver.ts
#angular #resolver
π© > Angular 15
β Link: https://stackblitz.com/edit/angular-2kiv4w?file=src%2Fapp%2Fhero-detail%2Fhero-detail.resolver.ts