yutasuzuki / react-native-record-screen

react-native-record-screen
MIT License
149 stars 40 forks source link

feat: return when recording permission is denied #89

Closed robrechtme closed 1 year ago

yutasuzuki commented 1 year ago

@robrechtme Thanks. Please let me consult with you. The "permission_error" is written in snake case. I would like to know the standard naming rules for other react native libraries, native android and native ios. If you know it, I would appreciate it if you could let me know.

robrechtme commented 1 year ago

Hi @yutasuzuki

There isn't really a convention, I've seen snake_case, UPPER_SNAKE_CASE and pascalCase being used. What would be a bit cleaner is using an object instead of plain strings, e.g.

const RecordingResult = {
  Started = 'started',
  PermissionError = 'permission_error'
} as const;

type RecordingResult = typeof RecordingResult[keyof typeof RecordingResult];

const res: RecordingResult = await RecordScreen.startRecording();

if (res === RecordingResult.PermissionError) {
  // user denies access
}

This would not break the current API as the started value is still the same.

yutasuzuki commented 1 year ago

@robrechtme That's great! I'd be happy to pull request that code!

robrechtme commented 1 year ago

Hi @yutasuzuki

I updated the code to do that 🙂