1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-12-21 13:13:58 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
sunnylqm
2024-01-18 00:22:17 +08:00
parent 7229f8847a
commit 9d93faab31
18 changed files with 2593 additions and 1200 deletions

26
src/context.ts Normal file
View 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);