Skip to content

Commit 251be13

Browse files
ms-nichoiandrewconnellVesaJuvonen
authored
Update Card view tutorial with caching documentation (SharePoint#7517)
* Update Card view tutorial with caching documentation * Update docs to reflect 1.14, not beta * Update advanced-card-view-functionality.md Updating preview note on the doc Co-authored-by: Andrew Connell <[email protected]> Co-authored-by: Vesa Juvonen <[email protected]>
1 parent 4ea65a5 commit 251be13

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

docs/spfx/viva/get-started/advanced-card-view-functionality.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
---
22
title: Advanced Card View Functionality
33
description: "This tutorial builds off the tutorial 'Build your first SharePoint Adaptive Card Extension'."
4-
ms.date: 10/25/2021
4+
ms.date: 02/18/2022
55
ms.prod: sharepoint
66
ms.localizationpriority: high
77
---
88
# Advanced Card View Functionality
99

1010
This tutorial builds off the following tutorial: [Build your first SharePoint Adaptive Card Extension](build-first-sharepoint-adaptive-card-extension.md)
1111

12+
> [!IMPORTANT]
13+
> This feature is still preview status as part of the 1.14 release and should not be used in production. We are looking into releasing them officially as part of the upcoming 1.15 release.
14+
1215
In this tutorial, you'll implement advanced card view functionality. You'll build off the the previous tutorial and create a card view that's powered by data in a SharePoint list.
1316

1417
## Create a test list
@@ -410,6 +413,45 @@ Select the **Next** button until you get to the last item in the list. The card
410413

411414
:::image type="content" source="../../../images/viva-extensibility/lab2-ace-6.png" alt-text="Card displaying the last item in the list with only a Previous button":::
412415

416+
## Caching Card view and ACE state
417+
418+
Starting in SPFx v1.14, ACEs have a client-side caching layer that can be configured to store:
419+
420+
1. The latest rendered card.
421+
2. The state of the ACE.
422+
423+
### Rendering from cached Card view
424+
425+
If the latest rendered card is stored, the Dashboard renders this cached card before the ACE is initialized, improving perceived performance.
426+
427+
The settings for this cache can be configured by overriding the following method:
428+
429+
```typescript
430+
protected getCacheSettings(): Partial<ICacheSettings> {
431+
return {
432+
isEnabled: true, // can be set to false to disable caching
433+
expiryTimeInSeconds: 86400, // controls how long until the cached card and state are stale
434+
cachedCardView: () => new CardView() // function that returns the custom Card view that will be used to generate the cached card
435+
};
436+
}
437+
```
438+
439+
### Rehydrating from cached ACE state
440+
441+
The subset of the ACE state that is cached can be configured by overriding the following method:
442+
443+
```typescript
444+
protected getCachedState(state: TState): Partial<TState>;
445+
```
446+
447+
The object returned by this method will be serialized and cached. By default, no state is cached. In the next call to `onInit`, the deserialized value will be passed to onInit as part of the `ICachedLoadParameters`
448+
449+
```typescript
450+
public onInit(cachedLoadParameters?: ICachedLoadParameters): Promise<void>;
451+
```
452+
453+
The value can then be used to rehydrate the state of the newly initialized ACE.
454+
413455
## Conclusion
414456

415457
After this lab you should be familiar with:
@@ -419,3 +461,4 @@ After this lab you should be familiar with:
419461
- Creating and registering Card views
420462
- Conditionally rendering Card view elements
421463
- Advanced Card view manipulation
464+
- Caching Card view and ACE state

0 commit comments

Comments
 (0)