const randomDataCheck = (data): Result<string> => {
if (!data) return err('No data available');
return ok('Data was provided');
};
const result = randomDataCheck('Some data');
if (result.isErr()) {
console.error(result.error.message); // "error message"
return;
}
const dataCheckRes = result.value;
This way we always know what's getting returned and it ensures we're checking each response before proceeding. It also helps keep our responses consistent across projects. I would be happy to create a PR with these changes if you believe it would benefit the bdk-rn library.
Do you have any thoughts/feelings on updating the method return response for increased clarity on returned types?
At Synonym we use the following: https://www.npmjs.com/package/@synonymdev/result
Example Usage:
This way we always know what's getting returned and it ensures we're checking each response before proceeding. It also helps keep our responses consistent across projects. I would be happy to create a PR with these changes if you believe it would benefit the bdk-rn library.