Skip to content
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

Functional API's setup should accept Promises in getStoredClient #542

Closed
mrcnk opened this issue Jan 12, 2024 · 1 comment
Closed

Functional API's setup should accept Promises in getStoredClient #542

mrcnk opened this issue Jan 12, 2024 · 1 comment

Comments

@mrcnk
Copy link
Member

mrcnk commented Jan 12, 2024

Current implementation of setup only accepts sync getters for getStoredClient. To make a better DX with Chrome extensions we should refactor setup to accept Promise<string> as a part of chrome.storage.local.

@mrcnk
Copy link
Member Author

mrcnk commented Jan 15, 2024

Current workaround if using async storages (like Chrome storage or React Native storage):
Get the persisted client state (as serialized string) in async function and pass it to the setup as:

async onSubmit(values) {
    const client = (await AsyncStorage.getItem("storedClient"))?.toString() ?? "";
    const paired = await setup({
        deviceId: values.deviceId,
        password: values.password,
        name: "Wallet",
        getStoredClient: () => client,
        setStoredClient,
    });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@mrcnk @netbonus and others