-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(expo): add ExpoClientStorage
for persisted store in RN
#3307
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Ignored Deployments
|
Apply Sweep Rules to your PR?
|
6896b64
to
b9a1829
Compare
✅ |
ExpoClientStorage
for persisted store on RNExpoClientStorage
for persisted store in RN
2615998
to
d81ad52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clever solution to a hard problem. Looks good from structural perspective. A bunch of nitpicky style comments.
packages/expo-polyfills/src/index.ts
Outdated
class SyncSecureStorage implements Storage { | ||
private readonly storage: Map<string, string>; | ||
private readonly initPromise: Promise<void>; | ||
private isInitialized = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably pedantic, but I think the recommended model for boolean naming is:
- noun for the variable name (i.e.,
initialized
) is
prefix for a getter (i.e.,isInitialized()
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True,
In this case was trying to avoid collision with initialized
Promise on the object... but yeah you're 100% right
packages/expo-polyfills/package.json
Outdated
@@ -42,6 +43,7 @@ | |||
"esbuild": "0.19.5", | |||
"esbuild-node-externals": "1.9.0", | |||
"jest": "29.7.0", | |||
"jest-expo": "^49.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why jest-expo
? I don't see any calls to it. And it's big :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the test environment for Expo, it actually fixes a lot of problems with react-native
preset, and better represents the various environments for Android
, iOS
, and Web
as separate environments. See the jest.config.json
:
"projects": [{ "preset": "jest-expo/ios" }, { "preset": "jest-expo/android" }], |
After the introduction of the If you want to wait to load components until after the import { MedplumClient } from '@medplum/core';
import { MedplumProvider, useMedplumContext } from '@medplum/react-hooks';
import { polyfillMedplumWebAPIs, ExpoClientStorage } from '@medplum/expo-polyfills';
polyfillMedplumWebAPIs();
const medplum = new MedplumClient({ storage: new ExpoClientStorage() });
function Home(): JSX.Element {
const { loading } = useMedplumContext();
return loading ? <div>Loading...</div> : <div>Loaded!</div>;
}
function App(): JSX.Element {
return (
<MedplumProvider medplum={medplum}>
<Home />
</MedplumProvider>
);
} Any thoughts @codyebberson @rhys-jmc ? |
12cfbb5
to
6aacaed
Compare
Kudos, SonarCloud Quality Gate passed! |
private secureStorage?: SyncSecureStorage; | ||
constructor() { | ||
// Metro should automatically prune these branches out at compile time | ||
if (Platform.OS === 'web') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this seem like a sane way to handle the React Native Web
case? These checks should compile out when Metro
compiles the final app. @codyebberson
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable - it's exported by Expo, so feels official.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks @ThatOneBro
Refinements and additions fot Health Gorilla documentation as we proceed through testing (#3333) Tighter input validation on security endpoints (#3334) Use react-jsx transform (#3338) Create documentation for chained search (#3312) Document performing insurance eligibility checks (#3280) feat(expo): add `ExpoClientStorage` for persisted store in RN (#3307) test(server): add `test.config.json` with port `8104` (#3329) Make Postgres version configurable in CDK (#3327) Configure agent service name and automatic start (#3321) Link authentication methods to relevant Medplum Client functions (#3323) server centralize request validation for co-location and reduced redundancy (#3228) Fixed FHIR link (#3319)
Refinements and additions fot Health Gorilla documentation as we proceed through testing (#3333) Tighter input validation on security endpoints (#3334) Use react-jsx transform (#3338) Create documentation for chained search (#3312) Document performing insurance eligibility checks (#3280) feat(expo): add `ExpoClientStorage` for persisted store in RN (#3307) test(server): add `test.config.json` with port `8104` (#3329) Make Postgres version configurable in CDK (#3327) Configure agent service name and automatic start (#3321) Link authentication methods to relevant Medplum Client functions (#3323) server centralize request validation for co-location and reduced redundancy (#3228) Fixed FHIR link (#3319)
Needs some cleanup but mostly done. Working well on Android device. Still need to add a few tests too.
Fixes #3301
TODO:
OperationOutcomeError
.catch
sremoveKey
invoking several calls tosetKeys
inclear
MedplumProvider
setting and unsettingloading
initialized
and what it meansloading
state fromuseMedplumContext