Skip to content

Commit a2e5ede

Browse files
Updated documentation for new and changed functionality
1 parent 4bad8b7 commit a2e5ede

18 files changed

Lines changed: 251 additions & 19 deletions

doc/docs/guide/01-getting-started.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ The `withHypermediaResource` feature also adds a property called `<ModelName>Sta
145145
```ts
146146
// A signal toggling between true and false to indicate if the
147147
// resource was loaded at least once from the backend
148-
const isLoadedSignal = this.store.flightModelState.isLoaded;
148+
const isLoadedSignal = store.flightModelState.isLoaded;
149149
// A signal toggling between true and false to indicate if an HTTP
150150
// request is currently running to get the state of this resource
151-
const isLoadingSignal = this.store.flightModelState.isLoading;
151+
const isLoadingSignal = store.flightModelState.isLoading;
152152
```
153153

154154
## 2. Make Mutations to the State
@@ -299,11 +299,11 @@ The `withHypermediaAction` adds a method with the specified name to the store to
299299
```ts
300300
// A signal indicating if the action is available, means the specified
301301
// metadata is available in the currently loaded resource.
302-
const isAvailableSignal = this.store.updateFlightConnectionState.isAvailable;
302+
const isAvailableSignal = store.updateFlightConnectionState.isAvailable;
303303
// A signal indicating if a request is currently running. Means a request
304304
// was sent to the backend and the client is waiting for the response. You
305305
// can use this e.g. for showing a loading spinner or progress bar in your UI.
306-
const isExecutingSignal = this.store.updateFlightConnectionState.isExecuting;
306+
const isExecutingSignal = store.updateFlightConnectionState.isExecuting;
307307
```
308308

309309
## Full Example

doc/docs/guide/configuration/01-metadata-provider.md renamed to doc/docs/guide/03-configuration/01-metadata-provider.md

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

doc/docs/guide/loading_features/01-withHypermediaResource.md renamed to doc/docs/guide/04-loading_features/01-withHypermediaResource.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Loads the resource from the provided URL.
5353

5454
### Load the Resource from a Link
5555
```ts
56-
load<resourceName>FromLink(linkRoot: unknown, linkName: string) => Promise<void>
56+
load<resourceName>FromLink(linkRoot: unknown, linkName: string): Promise<void>
5757
```
5858
Loads the resource from the provided URL.
5959

doc/docs/guide/loading_features/02-withInitialHypermediaResource.md renamed to doc/docs/guide/04-loading_features/02-withInitialHypermediaResource.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Loads the resource from the provided URL.
5454

5555
### Load the Resource from a Link
5656
```ts
57-
load<resourceName>FromLink(linkRoot: unknown, linkName: string) => Promise<void>
57+
load<resourceName>FromLink(linkRoot: unknown, linkName: string): Promise<void>
5858
```
5959
Loads the resource from the provided URL.
6060

doc/docs/guide/loading_features/03-withLinkedHypermediaResource.md renamed to doc/docs/guide/04-loading_features/03-withLinkedHypermediaResource.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Creates a resource in the store which loads depending on a signal pointing to a
88
## API
99
```ts
1010
function withLinkedHypermediaResource<ResourceName extends string, TResource, Input extends SignalStoreFeatureResult>(
11-
resourceName: ResourceName, initialValue: TResource, linkRootFn: ResourceLinkRootFn<Input>, linkMetaName: string):
12-
SignalStoreFeature;
11+
resourceName: ResourceName, initialValue: TResource, linkRootFn: ResourceLinkRootFn<Input>, linkMetaName: string
12+
): SignalStoreFeature;
1313
```
1414

1515
* **resourceName**: The name of how the resource will be declared in the store.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# withWritableStateCopy
6+
Creates a writable copy of selected state signals. The copy is linked to the original signals. If the state original signals change, the writable copy will reflect those changes. Writing to the writable copy will not update the original state signals. Furthermore the wiritable copy is also a deep signal so that you get fine grained reactivity when working with your copy.
7+
8+
## API
9+
```ts
10+
function withWritableStateCopy<Input extends SignalStoreFeatureResult, StateSelection extends ObjectWithSignalsForStateCopy>(
11+
stateMapFn: (store: StateSignals<Input['state']>) => StateSelection
12+
): SignalStoreFeature;
13+
```
14+
15+
* **stateMapFn**: A selector function that receives the store's state signals and returns an object describing which signals (and nested signal objects) should be exposed as a writable copy. The object can also contain nested objects, which will be recursively mapped. The result of the function shall comply with the following type definition:
16+
17+
```ts
18+
type ObjectWithSignalsForStateCopy = {
19+
[key: string]: Signal<unknown> | ObjectWithSignalsForStateCopy;
20+
}
21+
```
22+
23+
## Props
24+
This feature adds a set of properties to the interface of the store that are created with the following type definition:
25+
26+
```ts
27+
type WritableStateCopy<State extends ObjectWithSignalsForStateCopy> = {
28+
[Key in keyof State]: State[Key] extends ObjectWithSignalsForStateCopy ?
29+
WritableStateCopy<State[Key]>
30+
: State[Key] extends Signal<infer InnerType> ?
31+
WritableDeepSignal<InnerType> : never;
32+
};
33+
```
34+
In short this means that each signal you put to the `ObjectWithSignalsForStateCopy` will be mapped to a `WritableDeepSignal<InnerType>`, where `InnerType` is the type contained in the original signal. Nested objects will be recursively mapped to the same shape.
35+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# withExperimentalDeepWritableStateCopy
6+
Creates a writable copy of selected state signals. The copy is linked to the original signals. If the original state signals change, the writable copy will reflect those changes. Writing to the writable copy will not update the original state signals. Furthermore the wiritable copy is also a deep writable signal so that you get fine grained reactivity when working with your copy and additionally you can write deeply nested properties.
7+
8+
:::warning
9+
This feature is experimental and might change or be removed in future versions.
10+
:::
11+
12+
## API
13+
```ts
14+
function withExperimentalDeepWritableStateCopy<Input extends SignalStoreFeatureResult, StateSelection extends ObjectWithSignalsForStateCopy>(
15+
stateMapFn: (store: StateSignals<Input['state']>) => StateSelection
16+
): SignalStoreFeature;
17+
```
18+
19+
* **stateMapFn**: A selector function that receives the store's state signals and returns an object describing which signals (and nested signal objects) should be exposed as a deep writable copy. The object can also contain nested objects, which will be recursively mapped. The result of the function shall comply with the following type definition:
20+
21+
```ts
22+
type ObjectWithSignalsForDeepStateCopy = {
23+
[key: string]: Signal<unknown> | ObjectWithSignalsForDeepStateCopy;
24+
}
25+
```
26+
27+
## Props
28+
This feature adds a set of properties to the interface of the store that are created with the following type definition:
29+
30+
```ts
31+
type DeepWritableStateCopy<State extends ObjectWithSignalsForDeepStateCopy> = {
32+
[Key in keyof State]: State[Key] extends ObjectWithSignalsForDeepStateCopy ?
33+
DeepWritableStateCopy<State[Key]>
34+
: State[Key] extends Signal<infer InnerType> ?
35+
DeepWritableSignal<InnerType> : never;
36+
};
37+
```
38+
In short this means that each signal you put to the `ObjectWithSignalsForDeepStateCopy` will be mapped to a `DeepWritableSignal<InnerType>`, where `InnerType` is the type contained in the original signal. Nested objects will be recursively mapped to the same shape.
39+

0 commit comments

Comments
 (0)