Tomasz Ducin
independent consultant, architect, developer, trainer, speaker #architecture #performance #javascript #typescript #react #angular
Independent Consultant & Software Architect
Trainer, Speaker, JS/TS Expert
ArchitekturaNaFroncie.pl (ANF)
Warsaw, PL
🤨
sig = signal(t) // WritableSignal<T>
sig.set(t)
sig.update(oldT => newT)
sig.asReadonly() // Signal<T>
c = computed(() => sig())
e = effect(() => display(sig()))
// NO SUBSCRIBE, NO UNSUBSCRIBE
@defer {
<component />
}
@defer (<TRIGGER>) {
<component />
}
@defer (<TRIGGER>) {
<component />
} @placeholder (minimum 500ms) {
<placeholder>
}
@defer (<TRIGGER>) {
<component />
} @placeholder (minimum 500ms) {
<placeholder>
} @loading (after 100ms; minimum 1s) {
<loader>
}
@defer (<TRIGGER>) {
<component />
} @placeholder (minimum 500ms) {
<placeholder>
} @loading (after 100ms; minimum 1s) {
<loader>
} @error {
something went wrong!
}
😎
@Component({ … })
class SomeComponent {
constructor(private something: SomeService) {}
}
@Component({ … })
class SomeComponent {
#something = inject(SomeService)
}
@Component({ … })
class SomeComponent {
#something = inject(SomeService)
}
const injectSomething = () => {
const something = inject(SomeService)
return something
}
@Component({ … })
class SomeComponent {
#something = injectSomething()
}
const injectSomething = (PARAMS) => {
const something = inject(SomeService)
something.parametrizeAndAll(PARAMS)
return something
}
@Component({ … })
class SomeComponent {
#something = injectSomething(PARAMS)
}
const injectSomething = (PARAMS) => {
const something = inject(SomeService)
something.parametrizeAndAll(PARAMS)
const destroyRef = inject(DestroyRef)
something.subscribe()
destroyRef.onDestroy(() => { something.unsubscribe() })
return something
}
@Component({ … })
class SomeComponent {
#something = injectSomething(PARAMS)
}
const injectSomething = () => {...}
const injectElse = () => {...}
const injectSomethingElse = () => {
const something = injectSomething()
const else_ = injectElse()
return combine(something, else_)
}
@Component({ … })
class SomeComponent {
#somethingElse = injectSomethingElse()
}
Digest Cycle
async task ⚙️
async task ⚙️
async task ⚙️
Zone.js-based Change Detection
<article>
<p>{{ content() }}</p>
</article>
#content = signal('some content')
By Tomasz Ducin
independent consultant, architect, developer, trainer, speaker #architecture #performance #javascript #typescript #react #angular