stripe-terminal-react-native
stripe-terminal-react-native copied to clipboard
Request: Expose SDK state machines
Is your feature request related to a problem? Please describe.
I'm currently using the exposed callbacks like onDidChangeConnectionStatus
to update and expose the current status to render on my RN application. The states that I maintain in application may get out of sync in these cases
- App is backgrounded and hence not able to receive callbacks to update state
- During a JS refresh, a connected reader will remain connected and so 'onDidChangeConnectionStatus' would not get called
- Not possible to detect if a
discoverReaders()
is ongoing in another part of the app that didn't call it, when there is nodiscoveredReaders
in the vicinity - Not possible to subscribe to the same hook in multiple places in 1 application
Describe the solution you'd like
Would be great if there was a state machine that's exposed for the entire useStripeTerminal()
so that I don't have to maintain my own states that may get out of sync. Also makes it easier to avoid cases where I forget to cancelDiscovering()
or cancelInstallingUpdate()
.
Example states that would be great to have
connectionStatus = notConnected
| discoveringReaders
| connecting
| connected
installUpdateStatus = idle
| updateAvailable
| installingUpdate
| updateFailed
I'm not too familiar with how the SDK represents its states internally but these are some of the states I frequently wish I had access to
Describe alternatives you've considered
Currently use a few useStates()
on the hooks provided by the Terminal SDK but it gets out of sync