mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-12-21 13:13:58 +08:00
v10
This commit is contained in:
26
src/context.ts
Normal file
26
src/context.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
import { CheckResult, ProgressData } from './type';
|
||||
|
||||
const empty = {};
|
||||
const noop = () => {};
|
||||
|
||||
export const defaultContext = {
|
||||
checkUpdate: () => Promise.resolve(empty),
|
||||
switchVersion: noop,
|
||||
switchVersionLater: noop,
|
||||
markSuccess: noop,
|
||||
dismissError: noop,
|
||||
};
|
||||
|
||||
export const PushyContext = createContext<{
|
||||
checkUpdate: () => void;
|
||||
switchVersion: () => void;
|
||||
switchVersionLater: () => void;
|
||||
progress?: ProgressData;
|
||||
markSuccess: () => void;
|
||||
updateInfo?: CheckResult;
|
||||
lastError?: Error;
|
||||
dismissError: () => void;
|
||||
}>(defaultContext);
|
||||
|
||||
export const usePushy = () => useContext(PushyContext);
|
||||
Reference in New Issue
Block a user