Slide 1

Slide 1 text

@ManfredSteyer ManfredSteyer The New NGRX Signal Store for Angular 3+n Flavors of the Signal Store

Slide 2

Slide 2 text

@ManfredSteyer Signal as Producer 4711 Consumer read set notify 4712

Slide 3

Slide 3 text

@ManfredSteyer Signal Eventually Zone-less!

Slide 4

Slide 4 text

@ManfredSteyer flights = signal([]); const flights = await this.flightService.findAsPromise(from, to); this.flights.set(flights);

Slide 5

Slide 5 text

@ManfredSteyer from = signal('Paris'); to = signal('London'); flightRoute = computed(() => this.from() + ' to ' + this.to()); constructor() { effect(() => { console.log('from', this.from()); console.log('to', this.to()); }); }

Slide 6

Slide 6 text

@ManfredSteyer

Slide 7

Slide 7 text

@ManfredSteyer

Slide 8

Slide 8 text

@ManfredSteyer

Slide 9

Slide 9 text

@ManfredSteyer

Slide 10

Slide 10 text

@ManfredSteyer

Slide 11

Slide 11 text

@ManfredSteyer Component Store "Intention" Signals sync/ async computed(…) computed(…)

Slide 12

Slide 12 text

@ManfredSteyer

Slide 13

Slide 13 text

@ManfredSteyer

Slide 14

Slide 14 text

@ManfredSteyer

Slide 15

Slide 15 text

@ManfredSteyer Manfred Steyer

Slide 16

Slide 16 text

@ManfredSteyer

Slide 17

Slide 17 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 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

@ManfredSteyer

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

@ManfredSteyer

Slide 26

Slide 26 text

@ManfredSteyer

Slide 27

Slide 27 text

@ManfredSteyer export const FlightBookingStore = signalStore( […] withMethods((state) => { […] return { loadByCriteria: rxMethod((c$) => c$.pipe([…])) }; }), […] );

Slide 28

Slide 28 text

@ManfredSteyer export const FlightBookingStore = signalStore( […] withMethods((state) => { […] return { loadByCriteria: rxMethod((c$) => c$.pipe([…])) }; }), […] );

Slide 29

Slide 29 text

@ManfredSteyer export const FlightBookingStore = signalStore( […] withMethods((state) => { […] return { loadByCriteria: rxMethod((c$) => c$.pipe( filter(c => c.from.length >= 3 && c.to.length >= 3), debounceTime(300), switchMap((c) => flightService.find(c.from, c.to)), tap(flights => patchState(state, { flights })) )) }; }), […] );

Slide 30

Slide 30 text

@ManfredSteyer export const FlightBookingStore = signalStore( […] withMethods((state) => { […] return { loadByCriteria: rxMethod((c$) => c$.pipe( filter(c => c.from.length >= 3 && c.to.length >= 3), debounceTime(300), switchMap((c) => flightService.find(c.from, c.to)), tap(flights => patchState(state, { flights })) )) }; }), […] );

Slide 31

Slide 31 text

@ManfredSteyer export const FlightBookingStore = signalStore( […] withHooks({ onInit({ loadByCriteria, criteria }) { loadByCriteria(criteria); }, }), ); takes: Signal, Observable, T

Slide 32

Slide 32 text

@ManfredSteyer

Slide 33

Slide 33 text

@ManfredSteyer const BookingStore = signalStore( withEntities() );

Slide 34

Slide 34 text

@ManfredSteyer

Slide 35

Slide 35 text

@ManfredSteyer

Slide 36

Slide 36 text

@ManfredSteyer

Slide 37

Slide 37 text

@ManfredSteyer Free eBook (6th Edition) ANGULARarchitects.io/book 20 Chapters 4 new Signal Store Chapters

Slide 38

Slide 38 text

@ManfredSteyer Signals: Future of CD Take Care of Data Flow Stores are the Missing Link Signal Store Lightweight Highly Extensible

Slide 39

Slide 39 text

@ManfredSteyer

Slide 40

Slide 40 text

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