Akita is a fantastic and lightweight library for state management.
<namespace>
L <namespace>.store.ts
L <namespace>.service.ts
L <namespace>.query.ts
Akita is a fantastic and lightweight library for state management.
<namespace>
L <namespace>.store.ts
L <namespace>.service.ts
L <namespace>.query.ts
// best practice arch | |
// app | |
// L core | |
// L core.module.ts | |
// L core.providers.ts | |
// L core.model.ts | |
// core.module.ts | |
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core'; |
// best practice arch | |
// app | |
// L hooks | |
// L useIsSsr.hook.ts | |
// useIsSsr.hook.ts | |
import { useState, useEffect } from "react"; | |
const useIsSsr = () => { | |
const [isSsr, setIsSsr] = useState(true); |
// core.providers.ts | |
import { APP_INITIALIZER } from '@angular/core'; | |
export const load<domain>ServiceFnFactory = (<domain>Service: <domain>Service): (() => Promise<any>) => () => { | |
<domain>Service.init(); | |
return Promise.resolve(); | |
}; | |
export const APP_INITIALIZER_PROVIDERS: Provider[] = [ | |
{ |
An Angular carousel created with SwiperJs.
Carousel component is programmed to accept every kind of template passed as carouselItem
and return data passed as carouselData
to the template.
This "short circuit" allows the Carousel component to stay transparent and agnostic, delegating the logic and design to the component that uses the Carousel.
As developers, we strive to write robust and error-free code. One of the ways to achieve this is by leveraging TypeScript's powerful type inference system.
This code snippet demonstrates how we can infer TypeScript types from JavaScript variables using the as const
syntax.
By using the as const
syntax, we can tell TypeScript that the variable's values are constant and should not be mutated.
This allows TypeScript to infer literal types for the values, making our code more type-safe and reducing the likelihood of runtime errors.