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

Make store.getId() fail-safe #15

Closed
kabirbaidhya opened this issue Jul 26, 2019 · 3 comments · Fixed by #18
Closed

Make store.getId() fail-safe #15

kabirbaidhya opened this issue Jul 26, 2019 · 3 comments · Fixed by #18
Assignees

Comments

@kabirbaidhya
Copy link
Contributor

kabirbaidhya commented Jul 26, 2019

export function getId(): string | undefined {

export function getId(): string | undefined {
const activeDomain = getActiveDomain();
return activeDomain && activeDomain[ID_KEY];
}
/**
* Get the store from the active domain.
*
* @returns {*}
*/
function getStore(): any {
const activeDomain = getActiveDomain();
if (!activeDomain) {
throw new Error('No active domain found in store.');
}
return activeDomain[STORE_KEY];
}

@cham11ng We either need to make store.getId() fail-safe like find() or we'll need to create a new fail-safe version eg: findId().

cc @mesaugat

@kabirbaidhya kabirbaidhya added the enhancement New feature or request label Jul 26, 2019
@kabirbaidhya kabirbaidhya removed the enhancement New feature or request label Jul 26, 2019
@cham11ng
Copy link
Contributor

cham11ng commented Jul 27, 2019

If the domain is not found, it returns undefined. It's already safe. But we need to test of getId for initialized and not initialized case.

@kabirbaidhya
Copy link
Contributor Author

Yes, we need a couple of tests to make sure this is fail-safe.

@cham11ng
Copy link
Contributor

Added some test cases for getId()

#18

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

Successfully merging a pull request may close this issue.

2 participants