File tree 2 files changed +53
-3
lines changed
2 files changed +53
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ sidebar_label : Functional Creation (NEW)
3
+ sidebar_position : 1
4
+ title : Functional Creation
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ The new Functional Creation API lets you create and configure ` RxState ` in only one place.
10
+
11
+ ## Example
12
+
13
+ ``` typescript
14
+ import { RxFor } from ' @rx-angular/template/for' ;
15
+
16
+ @Component ({
17
+ template: ` <movie *rxFor="let movie of movies$" [movie]="movie" /> ` ,
18
+ imports: [RxFor ],
19
+ })
20
+ export class MovieListComponent {
21
+ private state = rxState <{ movies: Movie [] }>(({ set }) => {
22
+ // set initial state
23
+ set ({ movies: [] });
24
+ });
25
+
26
+ // select a property for the template to consume
27
+ movies$ = this .state .select (' movies' );
28
+ }
29
+ ```
30
+
31
+ ## Signature
32
+
33
+ The functional creation API is based on the class-based ` RxState ` API, more details about the signature [ here] ( ./rx-state ) .
34
+
35
+ ``` typescript
36
+ import { RxState as LegacyState } from ' @rx-angular/state' ;
37
+
38
+ export type RxState <T extends object > = Pick <
39
+ LegacyState <T >,
40
+ ' get' | ' select' | ' connect' | ' set' | ' $' | ' setAccumulator'
41
+ >;
42
+
43
+ export type RxStateSetupFn <State extends object > = (
44
+ rxState : Pick <RxState <State >, ' connect' | ' set' | ' setAccumulator' >
45
+ ) => void ;
46
+
47
+ export function rxState<State extends object >(
48
+ setupFn ? : RxStateSetupFn <State >
49
+ ): RxState <State >;
50
+ ```
Original file line number Diff line number Diff line change 1
1
---
2
2
sidebar_label : RxState
3
- sidebar_position : 1
3
+ sidebar_position : 2
4
4
title : RxState
5
5
# Moved from libs/state/api/
6
6
---
7
7
8
8
## Overview
9
9
10
- RxState is a light-weight reactive state management service for managing local state in angular .
10
+ ` RxState ` is a light-weight reactive state management service for managing local state in Angular .
11
11
12
- _ Example _
12
+ ## Example
13
13
14
14
``` typescript
15
15
Component ({
You can’t perform that action at this time.
0 commit comments