Slide 1

Slide 1 text

@ManfredSteyer ManfredSteyer Angular Architectures with Signals

Slide 2

Slide 2 text

@ManfredSteyer Signal as Producer 4711 Consumer read set notify 4712

Slide 3

Slide 3 text

@ManfredSteyer

Slide 4

Slide 4 text

@ManfredSteyer

Slide 5

Slide 5 text

@ManfredSteyer Manfred Steyer

Slide 6

Slide 6 text

@ManfredSteyer

Slide 7

Slide 7 text

@ManfredSteyer @Injectable({ providedIn: 'root' }) export class FlightBookingFacade { […] private _flights = signal([]); readonly flights = this._flights.asReadonly(); async load(from: string, to: string) { const flights = await […]; this._flights.set(flights); } }

Slide 8

Slide 8 text

@ManfredSteyer @Injectable({ providedIn: 'root' }) export class FlightBookingFacade { […] private _flights = signal([]); readonly flights = this._flights.asReadonly(); async load(from: string, to: string) { const flights = await […]; this._flights.set(flights); } }

Slide 9

Slide 9 text

@ManfredSteyer @Injectable({ providedIn: 'root' }) export class FlightBookingFacade { […] private _flights = signal([]); readonly flights = this._flights.asReadonly(); private _from = signal('Hamburg'); readonly from = this._from.asReadonly(); private _to = signal('Graz'); readonly to = this._to.asReadonly(); […] }

Slide 10

Slide 10 text

@ManfredSteyer

Slide 11

Slide 11 text

@ManfredSteyer select(selector) selectSignal(selector)

Slide 12

Slide 12 text

@ManfredSteyer

Slide 13

Slide 13 text

@ManfredSteyer

Slide 14

Slide 14 text

@ManfredSteyer @Injectable({ providedIn: 'root' }) export class FlightBookingFacade { private state = signalState({ from: 'Paris', to: 'London', flights: [] as Flight[], basket: {} as Record, }); readonly flights = this.state.flights; readonly from = this.state.from; […] }

Slide 15

Slide 15 text

@ManfredSteyer @Injectable({ providedIn: 'root' }) export class FlightBookingFacade { […] readonly selected = computed( () => this.flights().filter((f) => this.basket()[f.id]) ); […] }

Slide 16

Slide 16 text

@ManfredSteyer @Injectable({ providedIn: 'root' }) export class FlightBookingFacade { […] updateCriteria(from: string, to: string): void { patchState(this.state, { from, to }) } […] }

Slide 17

Slide 17 text

@ManfredSteyer @Injectable({ providedIn: 'root' }) export class FlightBookingFacade { […] swap(): void { patchState(this.state, (state) => ({ from: state.to, to: state.from })); } […] }

Slide 18

Slide 18 text

@ManfredSteyer @Injectable({ providedIn: 'root' }) export class FlightBookingFacade { […] updateCriteria(from: string, to: string): void { patchState(this.state, updateRoute(from, to)); } […] } function updateRoute(from: string, to: string) { return (state: T) => ({ from, to }) }

Slide 19

Slide 19 text

@ManfredSteyer

Slide 20

Slide 20 text

@ManfredSteyer export const FlightBookingStore = signalStore( { providedIn: 'root' }, […] );

Slide 21

Slide 21 text

@ManfredSteyer export const FlightBookingStore = signalStore( { providedIn: 'root' }, withState({ from: 'Paris', to: 'London', […] }), […] );

Slide 22

Slide 22 text

@ManfredSteyer export const FlightBookingStore = signalStore( { providedIn: 'root' }, withState({ from: 'Paris', to: 'London', […] }), withComputed(([…]) => ({ […] })), withMethods(([…]) => ({ })), withHooks({ […] }) );

Slide 23

Slide 23 text

@ManfredSteyer

Slide 24

Slide 24 text

@ManfredSteyer export const FlightBookingStore = signalStore( { providedIn: 'root' }, withState({ from: 'Paris', to: 'London', […] }), withSignals(([…]) => ({ […] })), withMethods(([…]) => ({ })), withHooks({ […] }), withCallState() );

Slide 25

Slide 25 text

@ManfredSteyer export const FlightBookingStore = signalStore( { providedIn: 'root' }, withState({ from: 'Paris', to: 'London', […] }), withSignals(([…]) => ({ […] })), withMethods(([…]) => ({ })), withHooks({ […] }), withCallState() );

Slide 26

Slide 26 text

@ManfredSteyer

Slide 27

Slide 27 text

@ManfredSteyer

Slide 28

Slide 28 text

@ManfredSteyer const BooksStore = signalStore( withEntities({ collection: 'book' }), withEntities({ collection: 'author' }) );

Slide 29

Slide 29 text

@ManfredSteyer Free eBook (5th Edition) ANGULARarchitects.io/book Module Federation & Nx

Slide 30

Slide 30 text

@ManfredSteyer Services + Signals NGRX NGRX Signal Store Different Flavors rxMethod Custom Features

Slide 31

Slide 31 text

@ManfredSteyer d Slides & Examples Remote Company Workshops and Consulting http://angulararchitects.io