You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Not really a problem. Considering developer experience, the library API can be improved.
Describe the solution you'd like
With the fluent interface, the usage will look like this:
importsmsReaderfrom"react-native-expo-read-sms";smsReader.withPermission().onRead(sms=>{/* do something with SMS string */smsReader.stop()}).onFail(error=>{/* do something with error; maybe stop reading */})
Describe alternatives you've considered
Support for Config
See notes in context about supporting config that goes with auto stop mechanism. In that case, the signature of the interface changes:
smsReader()// without config.withPermission().onRead(...).onFail(...)smsReader({maxOnReads: 5,stopOnFail: false}).withPermission().onRead(...).onFail(...)
Stop on failure
We can have implicit stop in case of failure so that the library user doesn't have to call stop inside onFail.
Additional context
In the fluent interface, the function withPermission() will ask for permission if not given already. If the user denies the permission, onRead will not be called.
As onRead and onFailure may be called multiple times, it's the user's responsibility to call stop whenever done. We can have an implicit limit on how many times onRead can be called. So that way even if the user forgets to call stop; we can stop listening whenever the counter completes. This counter mechanism can also allow (optional) configuration. Ideally that we can take as a param in the reader function: smsReader({ maxOnReads: 10 }). If the optional config is not provided, then the user will be smsReader()
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Not really a problem. Considering developer experience, the library API can be improved.
Describe the solution you'd like
With the fluent interface, the usage will look like this:
Describe alternatives you've considered
Support for Config
See notes in context about supporting config that goes with auto stop mechanism. In that case, the signature of the interface changes:
Stop on failure
We can have implicit
stop
in case of failure so that the library user doesn't have to callstop
insideonFail
.Additional context
withPermission()
will ask for permission if not given already. If the user denies the permission,onRead
will not be called.onRead
andonFailure
may be called multiple times, it's the user's responsibility to callstop
whenever done. We can have an implicit limit on how many timesonRead
can be called. So that way even if the user forgets to callstop
; we can stop listening whenever the counter completes. This counter mechanism can also allow (optional) configuration. Ideally that we can take as a param in the reader function:smsReader({ maxOnReads: 10 })
. If the optional config is not provided, then the user will besmsReader()
The text was updated successfully, but these errors were encountered: