You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SharePoint Framework services are instantiated with each WebPart consuming the service (see SharePoint#1419). SharePoint Framework libraries are not supported outside of the workbench. Both of these features of the framework should be avoided until 1) SPFX Framework services function as singletons as they are meant to and 2) SPFx Libraries can be built, distributed, and used within SP Online.
Copy file name to clipboardExpand all lines: docs/spfx/web-parts/guidance/share-data-between-web-parts.md
+1-104Lines changed: 1 addition & 104 deletions
Original file line number
Diff line number
Diff line change
@@ -313,109 +313,6 @@ export class DocumentsService {
313
313
314
314
The implementation of this service is very similar to when using cookies. One thing that you should keep in mind, however, is that browser storage can be disabled by the user, and you should always check for its availability before performing operations on it. Just as with cookies, local storage is persisted in the web browser and you should never use it to store any confidential information.
315
315
316
-
## Share data through a SharePoint Framework service
317
-
318
-
Another approach to sharing data between web parts is by building a SharePoint Framework service and using it to centrally load and manage data. SharePoint Framework services are standalone components built separately from web parts and distributed as separate Node packages. SharePoint Framework web parts can reference services and use them to perform specific operations supported by these services, such as loading data.
319
-
320
-
The existing service, demonstrated in previous examples, with just a few modifications, can be transformed into a SharePoint Framework service.
321
-
322
-
First, it needs to implement an interface that represents the operations and properties it supports:
Next, it needs to specify a [service key](https://docs.microsoft.com/en-us/javascript/api/sp-core-library/servicekey) used to register the service with the SharePoint Framework and consume it from within web parts:
Each SharePoint Framework service must also have a constructor that accepts an instance of the [ServiceScope](https://docs.microsoft.com/en-us/javascript/api/sp-core-library/servicescope) class as a parameter.
356
-
357
-
SharePoint Framework services can be built using the same project build system as SharePoint Framework client-side web parts. Similar to a client-side web part, a SharePoint Framework service has a manifest. The main difference with the web part manifest is that the `componentType` property is set to `Library`:
Even if there are multiple web parts on the page referencing the same service, its bundle is downloaded only once, and the SharePoint Framework creates only one instance of the service on the page. This offers you a convenient mechanism for centralizing processing and storing data on a page.
416
-
417
-
While working with SharePoint Framework services is more complex than the previously described approaches, it offers you the great benefits of isolating the data from other components on the page and better handling of its integrity.
418
-
419
316
## See also
420
317
421
-
-[Tutorial: Share data between web parts by using a global variable](./tutorial-share-data-between-web-parts-global-variable.md)
318
+
-[Tutorial: Share data between web parts by using a global variable](./tutorial-share-data-between-web-parts-global-variable.md)
0 commit comments