UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

30 lines 1.55 kB
import { PropsWithChildren } from 'react'; type GlobalIsEditingContextType = { /** If true, the user is editing a resource and should be presented with a warning before navigating away or performing * some other action that will destroy the unsaved changes */ isEditing: boolean; /** Function to set the editing state. This should be called when the user starts or stops editing a resource */ setIsEditing: (value: boolean) => void; }; type UnsubscribeFn = () => void; type SubscribeFn = (callback: () => void) => UnsubscribeFn; export type IsEditingStore = { subscribe: SubscribeFn; getSnapshot: () => boolean; setIsEditing: (value: boolean) => void; }; type GlobalIsEditingContextProviderProps = PropsWithChildren<IsEditingStore>; /** * Provider for context that tracks whether the user is currently editing a resource, to be used to prevent the user from * navigating away before changes are saved. * * This context provider does not itself implement the logic to prevent navigation, but provides an interface for * synchronizing with the editing state tracked in the application. */ export declare function GlobalIsEditingContextProvider(props: GlobalIsEditingContextProviderProps): import("react/jsx-runtime").JSX.Element; /** * Hook to access the global editing context so the application can prevent navigation away from a page if a resource is being edited. */ export declare function useGlobalIsEditingContext(): GlobalIsEditingContextType; export {}; //# sourceMappingURL=GlobalIsEditingContext.d.ts.map